# frozen_string_literal: true require "erb" require "rerb" require "rerb/compiler" module RERB class Templater TEMPLATE = "<%= content %>" def initialize(filename, root_name) @viewmodel_name = File.basename(filename, ".*").split("_").map(&:capitalize).join @root_name = root_name end def generate(input) content = Compiler.new(input, @viewmodel_name, @root_name) .compile rhtml = ERB.new(self.class::TEMPLATE) rhtml.result(binding) end end class IIFETemplater < Templater TEMPLATE = <<~TMPL.chomp
TMPL end class UMDTemplater < Templater TEMPLATE = <<~TMPL.chomp
TMPL end end