Module: Roda::RodaPlugins::PrecompileTemplates::ClassMethods

Defined in:
lib/roda/plugins/precompile_templates.rb

Instance Method Summary collapse

Instance Method Details

#precompile_templates(pattern, opts = OPTS) ⇒ Object

Precompile the templates using the given options. See PrecompileTemplates for details.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/roda/plugins/precompile_templates.rb', line 51

def precompile_templates(pattern, opts=OPTS)
  if pattern.is_a?(Hash)
    opts = pattern.merge(opts)
  end

  if locals = opts[:locals]
    locals.sort!
  else
    locals = EMPTY_ARRAY
  end

  compile_opts = if pattern.is_a?(Hash)
    [opts]
  else
    Dir[pattern].map{|file| opts.merge(:path=>File.expand_path(file, nil))}
  end

  instance = allocate
  compile_opts.each do |compile_opt|
    template = instance.send(:retrieve_template, compile_opt)
    template.send(:compiled_method, locals)
  end

  nil
end