class Tilt::TwigTemplate
Public Instance Methods
evaluate(scope, locals, &block)
click to toggle source
# File lib/tilt/twig.rb, line 12 def evaluate(scope, locals, &block) template_file = Tempfile.new(['template-', '.twig']) yaml_file = Tempfile.new(['context-', '.yml']) yaml_data = locals.merge(scope.is_a?(Hash) ? scope : {}).stringify_keys begin File.open(template_file.path, 'w'){|file| file.write(data)} File.open(yaml_file.path, 'w'){|file| file.write(yaml_data.to_yaml)} php_ini_path = "#{gem_root_path}/php/php.ini" renderer_path = "#{gem_root_path}/php/render.php" templates_path = File.dirname(template_file.path) template_name = File.basename(template_file.path) yaml_dump_path = yaml_file.path result = `php --php-ini "#{php_ini_path}" "#{renderer_path}" "#{templates_path}" "#{template_name}" "#{yaml_dump_path}"` rescue raise ensure template_file.close template_file.unlink yaml_file.close yaml_file.unlink end end
initialize_engine()
click to toggle source
# File lib/tilt/twig.rb, line 6 def initialize_engine install_php_dependencies end
prepare()
click to toggle source
# File lib/tilt/twig.rb, line 10 def prepare; end
Private Instance Methods
gem_root_path()
click to toggle source
# File lib/tilt/twig.rb, line 44 def gem_root_path File.expand_path '../../..', __FILE__ end
install_php_dependencies()
click to toggle source
# File lib/tilt/twig.rb, line 40 def install_php_dependencies Dir.chdir(gem_root_path){`php php/install.php`} end