class Ember::Emblem::Template
Public Class Methods
config()
click to toggle source
# File lib/ember/emblem/template.rb, line 18 def self.config @config ||= Config.new end
setup(env)
click to toggle source
# File lib/ember/emblem/template.rb, line 13 def self.setup(env) env.register_mime_type 'text/x-emblem', extensions: ['.emblem'] env.register_transformer 'text/x-emblem', 'application/javascript', Ember::Emblem::Template end
Public Instance Methods
evaluate(scope, locals, &block)
click to toggle source
# File lib/ember/emblem/template.rb, line 22 def evaluate(scope, locals, &block) template = data if config.precompile template = precompile_ember_emblem(template, config.ember_template) else template = compile_ember_emblem(template, config.ember_template) end target = global_template_target('Ember.TEMPLATES', scope.logical_path, config) "#{target} = #{template}\n" end
Private Instance Methods
compile_ember_handlebars(string, ember_template = 'Handlebars', options = nil)
click to toggle source
# File lib/ember/emblem/template.rb, line 51 def compile_ember_handlebars(string, ember_template = 'Handlebars', options = nil) handlebars = Precompiler.compile(string) "Ember.#{ember_template}.compile(#{indent(handlebars).inspect}, #{options.to_json});" end
config()
click to toggle source
# File lib/ember/emblem/template.rb, line 61 def config @config ||= self.class.config.dup end
precompile_ember_handlebars(string, ember_template = 'Handlebars', input = {}, options = nil)
click to toggle source
# File lib/ember/emblem/template.rb, line 56 def precompile_ember_handlebars(string, ember_template = 'Handlebars', input = {}, options = nil) handlebars = Precompiler.compile(string) "Ember.#{ember_template}.template(#{Barber::Ember::Precompiler.compile(handlebars, options)});" end
template_path(path, config)
click to toggle source
# File lib/ember/emblem/template.rb, line 37 def template_path(path, config) root = config.templates_root unless root.empty? Array(root).each.each do |r| path = path.sub(/#{Regexp.quote(r)}\//, '') end end path = path.split('/') path.join(config.templates_path_separator) end