Class: Musterb::TemplateHandler
Class Method Summary
collapse
Instance Method Summary
collapse
#block_end, #block_if, #block_unless, #change_token, #comment, #fetch, #initialize, #to_erb
Class Method Details
.call(template) ⇒ Object
23
24
25
26
27
|
# File 'lib/musterb/template_handler.rb', line 23
def self.call(template)
options = {}
options[:initial_context] = "initial_context" if template.locals.include? "initial_context"
compile_mustache(template.source, options)
end
|
.compile_mustache(source, options = {}) ⇒ Object
17
18
19
20
21
|
# File 'lib/musterb/template_handler.rb', line 17
def self.compile_mustache(source, options = {})
erb = Musterb.to_erb(source, options.merge(:musterbifier_klass => self))
klass = ActionView::Template::Handlers::ERB
klass.erb_implementation.new(erb, :trim => (klass.erb_trim_mode == "-")).src
end
|
Instance Method Details
#render_partial(partial) ⇒ Object
5
6
7
|
# File 'lib/musterb/template_handler.rb', line 5
def render_partial(partial)
"<%= render :partial => '#{partial}', :locals => {:initial_context => musterb.context} %>"
end
|
#text_with_escaping(tokens) ⇒ Object
13
14
15
|
# File 'lib/musterb/template_handler.rb', line 13
def text_with_escaping(tokens)
"<%= #{tokens} %>"
end
|
#text_without_escaping(tokens) ⇒ Object
9
10
11
|
# File 'lib/musterb/template_handler.rb', line 9
def text_without_escaping(tokens)
"<%= #{tokens}.html_safe %>"
end
|