Class: Assette::Template

Inherits:
File
  • Object
show all
Defined in:
lib/assette/template.rb

Instance Method Summary collapse

Methods inherited from File

#==, #all_code, #all_code_array, all_code_for, #check_config_flag, #code, #comment_str, #dependencies, #dev_tag, #dirname, #extension, #filename, #mime_type, #minify?, #never_minify?, #path_array, #puts, rack_resp_if_exists, #read, #read_config, #reader_class, #relative_target_path, #target_class, #target_path, #template_set, #templates, #text

Instance Method Details

#compileObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/assette/template.rb', line 4

def compile
  if Assette.config.template_partial && filename =~ /^_/
    format = Assette.config.template_partial.dup
  else
    format = Assette.config.template_format.dup
  end
  
  format.gsub!('{*path*}',local_path.to_json)
  format.gsub!('{*template*}',stringify_body)
end

#local_pathObject



19
20
21
22
23
24
# File 'lib/assette/template.rb', line 19

def local_path
  lp = path.gsub(Assette.config.templates_path,'')
  lp.gsub!(/((\.html)?\.\w+)$/,'').gsub!(/^\//,'')
  lp.gsub!(/\/_/,'/')
  lp
end

#stringify_bodyObject



15
16
17
# File 'lib/assette/template.rb', line 15

def stringify_body
  %Q{"""#{read}"""}
end