Module: Troy::Helpers
- Defined in:
- lib/troy/helpers.rb
Instance Method Summary collapse
- #h(content) ⇒ Object
- #inline_file(path) ⇒ Object
- #markdown(text) ⇒ Object
- #partial(name, locals = {}) ⇒ Object
- #t(*args) ⇒ Object
Instance Method Details
#h(content) ⇒ Object
3 4 5 |
# File 'lib/troy/helpers.rb', line 3 def h(content) CGI.escapeHTML(content) end |
#inline_file(path) ⇒ Object
18 19 20 |
# File 'lib/troy/helpers.rb', line 18 def inline_file(path) site.root.join(path).read end |
#markdown(text) ⇒ Object
22 23 24 |
# File 'lib/troy/helpers.rb', line 22 def markdown(text) Troy::Markdown.new(text).to_html end |
#partial(name, locals = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/troy/helpers.rb', line 11 def partial(name, locals = {}) path = site.root.join("partials/_#{name}.erb") EmbeddedRuby.new(path.read, locals.merge(site: site)).render rescue Exception, StandardError => error raise "Unable to render #{path}; #{error.}" end |
#t(*args) ⇒ Object
7 8 9 |
# File 'lib/troy/helpers.rb', line 7 def t(*args) I18n.t(*args) end |