diff --git a/lib/papercraft/compiler.rb b/lib/papercraft/compiler.rb index 5de896a..788786b 100644 --- a/lib/papercraft/compiler.rb +++ b/lib/papercraft/compiler.rb @@ -82,6 +82,12 @@ def visit_call_node(node) return super if node.receiver @html_location_start ||= node.location + + case node.name + when :text + return emit_html_text(node) + end + inner_text, attrs = tag_args(node) block = node.block @@ -166,4 +172,11 @@ def emit_tag_attribute_node(node, key = false) tag_attr_embed_visit(node, key) end end + + def emit_html_text(node) + args = node.arguments&.arguments + return nil if !args + + emit_tag_inner_text(args[0]) + end end diff --git a/lib/papercraft/tags.rb b/lib/papercraft/tags.rb index 5f53d28..3bfb787 100644 --- a/lib/papercraft/tags.rb +++ b/lib/papercraft/tags.rb @@ -218,9 +218,10 @@ def method_missing(sym, *args, **opts, &block) # Emits text into the rendering buffer, escaping any special characters to # the respective XML entities. # - # @param data [String] text + # @param data [String, nil] text # @return [void] - def text(data) + def text(data = nil) + return if !data return if @render_fragment && @fragment != @render_fragment @buffer << escape_text(data) diff --git a/test/fixtures/compiler/text.html b/test/fixtures/compiler/text.html new file mode 100644 index 0000000..fc072f8 --- /dev/null +++ b/test/fixtures/compiler/text.html @@ -0,0 +1 @@ +