Skip to content

Commit

Permalink
Fix compiler on Ruby 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
noteflakes committed Feb 19, 2024
1 parent 6774521 commit f5b6163
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/papercraft/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def fcall_inner_text_from_args(args)
case first.type
when :STR
first.children.first
when :LIT
when :LIT, :SYM
first.children.first.to_s
when :HASH
nil
Expand Down Expand Up @@ -246,7 +246,7 @@ def emit_tag_attribute_key(key)
case key.type
when :STR
emit_literal(key.children.first)
when :LIT
when :LIT, :SYM
emit_literal(key.children.first.to_s)
when :NIL
emit_literal('nil')
Expand All @@ -258,9 +258,11 @@ def emit_tag_attribute_key(key)
def emit_tag_attribute_value(value, key)
case value.type
when :STR
encoding = (key.type == :LIT) && (key.children.first == :href) ? :uri : :html
type = key.type
is_href_attr = (type == :LIT || type == :SYM) && (key.children.first == :href)
encoding = is_href_attr ? :uri : :html
emit_text(value.children.first, encoding: encoding)
when :LIT
when :LIT, :SYM
emit_text(value.children.first.to_s)
else
parse(value)
Expand Down Expand Up @@ -313,6 +315,11 @@ def parse_lit(node)
emit_literal(value.inspect)
end

def parse_sym(node)
value = node.children.first
emit_literal(value.inspect)
end

def parse_true(node)
emit_expression { emit_literal('true') }
end
Expand Down

0 comments on commit f5b6163

Please sign in to comment.