lib/faml/compiler.rb in faml-0.2.2 vs lib/faml/compiler.rb in faml-0.2.3

- old
+ new

@@ -1,10 +1,11 @@ require 'parser/current' require 'temple' require 'faml/ast' require 'faml/filter_compilers' require 'faml/helpers' +require 'faml/rails_helpers' require 'faml/static_hash_parser' require 'faml/text_compiler' module Faml class Compiler < Temple::Parser @@ -19,10 +20,11 @@ define_options( autoclose: DEFAULT_AUTO_CLOSE_TAGS, format: :html, preserve: DEFAULT_PRESERVE_TAGS, + use_html_safe: false, ) def initialize(*) super @text_compiler = TextCompiler.new @@ -69,11 +71,19 @@ raise "InternalError: Unknown AST node #{ast.class}: #{ast.inspect}" end end def compile_root(ast) - [:multi, [:code, 'extend ::Faml::Helpers']].tap do |temple| + [:multi, [:code, "extend ::#{helper_module.name}"]].tap do |temple| compile_children(ast, temple) + end + end + + def helper_module + if options[:use_html_safe] + RailsHelpers + else + Helpers end end def compile_children(ast, temple) ast.children.each do |c|