88class Herb ::CLI
99 include Herb ::Colors
1010
11- attr_accessor :json , :silent , :no_interactive , :no_log_file , :no_timing , :local , :escape , :no_escape , :freeze , :debug , :tool , :strict
11+ attr_accessor :json , :silent , :no_interactive , :no_log_file , :no_timing , :local , :escape , :no_escape , :freeze , :debug , :tool , :strict ,
12+ :auto_close_tags
1213
1314 def initialize ( args )
1415 @args = args
@@ -246,6 +247,10 @@ def option_parser
246247 self . strict = false
247248 end
248249
250+ parser . on ( "--auto-close-tags" , "Auto-insert closing tags for elements with omitted closing tags (for compile/render commands)" ) do
251+ self . auto_close_tags = true
252+ end
253+
249254 parser . on ( "--tool TOOL" , "Show config for specific tool: linter, formatter (for config command)" ) do |t |
250255 self . tool = t . to_sym
251256 end
@@ -294,6 +299,7 @@ def compile_template
294299 options [ :escape ] = no_escape ? false : true
295300 options [ :freeze ] = true if freeze
296301 options [ :strict ] = strict . nil? || strict
302+ options [ :auto_close_omitted_tags ] = auto_close_tags
297303
298304 if debug
299305 options [ :debug ] = true
@@ -309,6 +315,7 @@ def compile_template
309315 filename : engine . filename ,
310316 bufvar : engine . bufvar ,
311317 strict : options [ :strict ] ,
318+ auto_close_omitted_tags : options [ :auto_close_omitted_tags ] ,
312319 }
313320
314321 puts result . to_json
@@ -362,6 +369,7 @@ def render_template
362369 options [ :escape ] = no_escape ? false : true
363370 options [ :freeze ] = true if freeze
364371 options [ :strict ] = strict . nil? || strict
372+ options [ :auto_close_omitted_tags ] = auto_close_tags
365373
366374 if debug
367375 options [ :debug ] = true
@@ -379,6 +387,7 @@ def render_template
379387 output : rendered_output ,
380388 filename : engine . filename ,
381389 strict : options [ :strict ] ,
390+ auto_close_omitted_tags : options [ :auto_close_omitted_tags ] ,
382391 }
383392
384393 puts result . to_json
0 commit comments