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:
parent
c8e73a385b
commit
c67d79e14d
3 changed files with 19 additions and 6 deletions
|
@ -11,6 +11,9 @@ module Hamlit
|
|||
attr_quote: "'",
|
||||
escape_html: true,
|
||||
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
|
||||
|
|
|
@ -2,12 +2,19 @@ require 'haml'
|
|||
|
||||
module Hamlit
|
||||
class Parser
|
||||
OPTION_MAPS = {
|
||||
autoclose: :autoclose,
|
||||
}.freeze
|
||||
|
||||
def initialize(options = {})
|
||||
@options = options
|
||||
@options = Haml::Options.defaults.dup
|
||||
OPTION_MAPS.each do |temple, haml|
|
||||
@options[haml] = options[temple]
|
||||
end
|
||||
end
|
||||
|
||||
def call(template)
|
||||
Haml::Parser.new(template, Haml::Options.defaults).parse
|
||||
Haml::Parser.new(template, @options).parse
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ module Hamlit
|
|||
class TagCompiler
|
||||
def initialize(options = {})
|
||||
@quote = options[:attr_quote].inspect.freeze
|
||||
@format = options[:format]
|
||||
end
|
||||
|
||||
def compile(node, &block)
|
||||
|
@ -24,10 +25,12 @@ module Hamlit
|
|||
end
|
||||
|
||||
def compile_contents(node, &block)
|
||||
unless node.children.empty?
|
||||
return yield(node)
|
||||
end
|
||||
case
|
||||
when !node.children.empty?
|
||||
yield(node)
|
||||
else
|
||||
[:dynamic, node.value[:value]]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue