1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Create autoclose option

This commit is contained in:
Takashi Kokubun 2015-10-11 21:50:46 +09:00
parent c8e73a385b
commit c67d79e14d
3 changed files with 19 additions and 6 deletions

View file

@ -11,6 +11,9 @@ module Hamlit
attr_quote: "'", attr_quote: "'",
escape_html: true, escape_html: true,
pretty: false, pretty: false,
autoclose: %w(area base basefont br col command embed frame
hr img input isindex keygen link menuitem meta
param source track wbr),
) )
use Parser use Parser

View file

@ -2,12 +2,19 @@ require 'haml'
module Hamlit module Hamlit
class Parser class Parser
OPTION_MAPS = {
autoclose: :autoclose,
}.freeze
def initialize(options = {}) def initialize(options = {})
@options = options @options = Haml::Options.defaults.dup
OPTION_MAPS.each do |temple, haml|
@options[haml] = options[temple]
end
end end
def call(template) def call(template)
Haml::Parser.new(template, Haml::Options.defaults).parse Haml::Parser.new(template, @options).parse
end end
end end
end end

View file

@ -1,7 +1,8 @@
module Hamlit module Hamlit
class TagCompiler class TagCompiler
def initialize(options = {}) def initialize(options = {})
@quote = options[:attr_quote].inspect.freeze @quote = options[:attr_quote].inspect.freeze
@format = options[:format]
end end
def compile(node, &block) def compile(node, &block)
@ -24,10 +25,12 @@ module Hamlit
end end
def compile_contents(node, &block) def compile_contents(node, &block)
unless node.children.empty? case
return yield(node) when !node.children.empty?
yield(node)
else
[:dynamic, node.value[:value]]
end end
[:dynamic, node.value[:value]]
end end
end end
end end