Sha256: 39e0402de4b8841efa495ecaf68b857d0cca8359c47ec0e7ac0be6c54ef674fa
Contents?: true
Size: 856 Bytes
Versions: 3
Compression:
Stored size: 856 Bytes
Contents
# frozen_string_literal: true module Troy module Helpers def h(content) CGI.escapeHTML(content) end def t(*args, **kwargs) I18n.t(*args, **kwargs) end def partial(name, locals = {}) name = name.to_s basename = File.basename(name) dirname = File.dirname(name) partial = [] partial << dirname unless dirname.start_with?(".") partial << "_#{basename}.erb" partial = partial.join("/") path = site.root.join("partials/#{partial}") locals = locals.merge(site: site, page: page) EmbeddedRuby.new(path.read, locals).render rescue Exception => error raise "Unable to render #{path}; #{error.message}" end def inline_file(path) site.root.join(path).read end def markdown(text) Troy::Markdown.new(text).to_html end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
troy-0.0.39 | lib/troy/helpers.rb |
troy-0.0.38 | lib/troy/helpers.rb |
troy-0.0.37 | lib/troy/helpers.rb |