Sha256: f4231e688a5798e81f026d5440e8f1ee935aaed87992a3c706c6aa5ff0e57b05

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require "temple"

module Brut::FrontEnd::Templates
  autoload(:HTMLSafeString,"brut/front_end/templates/html_safe_string")
  autoload(:ERBParser,"brut/front_end/templates/erb_parser")
  autoload(:EscapableFilter,"brut/front_end/templates/escapable_filter")
  autoload(:BlockFilter,"brut/front_end/templates/block_filter")
  autoload(:ERBEngine,"brut/front_end/templates/erb_engine")
end

# Handles rendering HTML templates
class Brut::FrontEnd::Template

  TempleTemplate = Temple::Templates::Tilt(Brut::FrontEnd::Templates::ERBEngine,
                                           register_as: "html.erb")

  # Wraps a string that is deemed safe to insert into
  # HTML without escaping it.  This allows stuff like
  # <%= component(SomeComponent) %> to work without
  # having to remember to <%== all the time.
  def initialize(template_file_path)
    @tilt_template = Tilt.new(template_file_path)
  end

  def render_template(...)
    @tilt_template.render(...)
  end

  def self.escape_html(string)
    Brut::FrontEnd::Templates::EscapableFilter.escape_html(string)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
brut-0.0.1 lib/brut/front_end/template.rb