Sha256: aad429a4bcadf3b5d80c3ff0f3ef8e4b053a74e86ae9ef869a431c9254617f7b

Contents?: true

Size: 580 Bytes

Versions: 2

Compression:

Stored size: 580 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")
      locals = locals.merge(site: site, page: page)
      EmbeddedRuby.new(path.read, locals).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

2 entries across 2 versions & 1 rubygems

Version Path
troy-0.0.33 lib/troy/helpers.rb
troy-0.0.32 lib/troy/helpers.rb