Sha256: 2361e07f5e1dc90505c827cd836497757ff1817b14c793c5904db6703c323cc7

Contents?: true

Size: 921 Bytes

Versions: 2

Compression:

Stored size: 921 Bytes

Contents

# Encapsulates helper methods and instance variables to be rendered in the ERB templates.
class Lono::Template
  class Context
    extend Memoist
    include Lono::Template::Helper
    include Loader
    include Helpers # ERB
    include Dsl::Builder::Syntax # DSL

    def initialize(blueprint, options={})
      @blueprint, @options = blueprint, options
      load_variables
      load_project_helpers
    end

    # Take a hash and makes them instance variables in the current scope.
    # Use this in custom helper methods to make variables accessible to ERB templates.
    def instance_variables!(variables)
      variables.each do |key, value|
        instance_variable_set('@' + key.to_s, value)
      end
    end

    # For Lono::AppFile::Build usage of Thor::Action directory
    # For some reason a send(:binding) doesnt work but get_binding like this works.
    def get_binding
      binding
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lono-6.1.11 lib/lono/template/context.rb
lono-6.1.10 lib/lono/template/context.rb