Class: Amp::Help::ErbHelpEntry
- Defined in:
- lib/amp-front/help/help.rb
Overview
Represents a help entry that filters its help text through ERB before returning.
This is useful because some entries might have programmatic logic to them - for example, the built in “commands” entry lists all the commands in the user’s current workflow. That requires logic, and while we used to simply have that be its own class, we can now stuff it in an ERB file.
Note: if you want to use pretty text in an ERB entry, you will have to use ruby code to do so. Use the following shortcuts:
<%= "Ampfiles".bold.underline %> # bolds and underlines
<%= "some.code()".black.on_green %> # changes to black and sets green bg color
See our extensions to the String class for more.
Instance Method Summary collapse
-
#text(options = {}) ⇒ String
Returns the help text to display for this entry.
Methods inherited from HelpEntry
Constructor Details
This class inherits a constructor from Amp::Help::HelpEntry
Instance Method Details
#text(options = {}) ⇒ String
Returns the help text to display for this entry.
For an ERB entry, we run ERB on the text in the entry, while also exposing the options variable as local, so the ERB can access the user’s runtime options.
205 206 207 208 209 210 |
# File 'lib/amp-front/help/help.rb', line 205 def text( = {}) full_text = super() erb = ERB.new(full_text, 0, "-") erb.result binding end |