Sha256: 35b01b523fa4e93f646de3d590b59e9dbb0343aa5cd87c1d144aba657edacd54
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
class Lono::Template::Dsl class Builder include Lono::Template::Util include Lono::Template::Context::Loader include Fn include Helpers # built-in helpers include Lono::Template::Evaluate include Syntax extend Memoist def initialize(path, blueprint, options={}) @path, @blueprint, @options = path, blueprint, options @template = @path.sub("#{Lono.config.templates_path}/",'').sub(/\.rb$/,'') @cfn = {} end def build load_context evaluate_template_path(@path) # modifies @cfn build_template write_output template end # Useful for lono seed to get the template in memory def template load_context evaluate_template_path(@path) # modifies @cfn @cfn end memoize :template def build_template @results = YAML.dump(@cfn) end def write_output output_path = "#{Lono.config.output_path}/#{@blueprint}/templates" FileUtils.mkdir_p(output_path) path = "#{output_path}/#{@template}.yml" ensure_parent_dir(path) IO.write(path, @results) validate_yaml(path) unless @options[:quiet] pretty_path = path.sub("#{Lono.root}/",'') puts " #{pretty_path}" end end # Not using Lono::Template::Context because that works differently. # That is used to load a context object that is passed to RenderMePretty's context. # So that we can load context for params files and erb templates. # # In this case builder is actually the dsl context. # We want to load variables and helpers into this builder context directly. # This loads additional context. It looks very similar to Lono::Template::Context def load_context load_variables load_project_helpers end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lono-6.0.0 | lib/lono/template/dsl/builder.rb |