Sha256: 9b2d3e5d29d86c35bb080bde32c35c8fd1c9c24a7faaf30de595ecc6263bf5aa

Contents?: true

Size: 546 Bytes

Versions: 5

Compression:

Stored size: 546 Bytes

Contents

module Troy
  module Helpers
    def h(content)
      CGI.escapeHTML(content)
    end

    def t(*args)
      I18n.t(*args)
    end

    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.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

5 entries across 5 versions & 1 rubygems

Version Path
troy-0.0.31 lib/troy/helpers.rb
troy-0.0.30 lib/troy/helpers.rb
troy-0.0.29 lib/troy/helpers.rb
troy-0.0.28 lib/troy/helpers.rb
troy-0.0.27 lib/troy/helpers.rb