12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/ruby2js/filter/tagged_templates.rb', line 12
def on_send(node)
target, method, *args = node.children
return super unless target.nil? and es2015
tagged_methods = @options[:template_literal_tags] || [:html, :css]
if tagged_methods.include?(method) && args.length == 1
strnode = process args.first
if strnode.type == :str
strnode = strnode.updated(:dstr, [s(:str, strnode.children.first.chomp("\n"))])
elsif strnode.type == :dstr
if strnode.children.last.type == :str && strnode.children.last.children[0].end_with?("\n")
children = [*strnode.children.take(strnode.children.length - 1), s(:str, strnode.children.last.children[0].chomp)]
strnode = s(:dstr, *children)
end
else
return super
end
S(:taglit, s(:sym, method), strnode)
else
super
end
end
|