Closed swrobel closed 7 years ago
Like this:
module Hamlit
class Filters
class Es6 < TiltBase
def compile(node)
# branch with `@format` here if you want
compile_html(node)
end
private
def compile_html(node)
temple = [:multi]
temple << [:static, "<script>\n"]
temple << compile_with_tilt(node, 'es6', indent_width: 2)
temple << [:static, "\n</script>"]
temple
end
end
register :es6, Es6 # <-- this part
end
end
Unfortunately Hamlit doesn't have the compatible interface with register_tilt_filter
(it generates a filter for Tilt and inherits existing one if necessary, and it depends on Haml's internal).
I hope the above code works for your use case.
Thank you so much for the quick reply. That worked perfectly. 😁
How do I register a custom filter, say babel-transpiler for es6?