wlang 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +17 -3
- data/README.md +56 -0
- data/lib/wlang.rb +9 -0
- data/lib/wlang/scope.rb +2 -0
- data/lib/wlang/scope/sinatra_scope.rb +49 -0
- data/lib/wlang/tilt.rb +3 -0
- data/lib/wlang/tilt/wlang_template.rb +44 -0
- data/lib/wlang/version.rb +1 -1
- data/spec/integration/tilt/test_wlang_template.rb +13 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/unit/scope/sinatra_scope/test_fetch.rb +28 -0
- data/spec/unit/scope/test_coerce.rb +4 -0
- data/spec/unit/tilt/test_wlang_template.rb +61 -0
- data/wlang.gemspec +2 -0
- metadata +114 -71
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e82a5d9c33a44f4d44068433fc341ac105eb6b0abb5859315264fc9c9039af3b
         | 
| 4 | 
            +
              data.tar.gz: a3ed2db115e809a220e1e0046e8b60178e7c093e03c3ba0eb558ef3e24c6c356
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ccc8a54926e97ef4a4b4f8b49669f2ea3b1e2e4421900ebf4f4a05d1094b5121145f607b98d4e56ced1224e1c53f728df0028631058301bad315baab080ebce1
         | 
| 7 | 
            +
              data.tar.gz: 95b57dc614446eddc46eb3eafec0a3b9470a3b440afdfd8ebf2c7c555aea3ae35ab34cdf6d4081e58b889a5c6057efc4d8767f694fd978a3b57fdd300559ceb0
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                wlang (3.0. | 
| 4 | 
            +
                wlang (3.0.1)
         | 
| 5 5 | 
             
                  citrus (~> 3.0)
         | 
| 6 6 | 
             
                  path (~> 2.0)
         | 
| 7 7 | 
             
                  quickl (~> 0.4.3)
         | 
| @@ -12,8 +12,13 @@ GEM | |
| 12 12 | 
             
              specs:
         | 
| 13 13 | 
             
                citrus (3.0.2)
         | 
| 14 14 | 
             
                diff-lcs (1.4.4)
         | 
| 15 | 
            +
                mustermann (1.1.1)
         | 
| 16 | 
            +
                  ruby2_keywords (~> 0.0.1)
         | 
| 15 17 | 
             
                path (2.0.1)
         | 
| 16 18 | 
             
                quickl (0.4.3)
         | 
| 19 | 
            +
                rack (2.2.3)
         | 
| 20 | 
            +
                rack-protection (2.1.0)
         | 
| 21 | 
            +
                  rack
         | 
| 17 22 | 
             
                rake (13.0.3)
         | 
| 18 23 | 
             
                rspec (3.10.0)
         | 
| 19 24 | 
             
                  rspec-core (~> 3.10.0)
         | 
| @@ -28,15 +33,24 @@ GEM | |
| 28 33 | 
             
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 29 34 | 
             
                  rspec-support (~> 3.10.0)
         | 
| 30 35 | 
             
                rspec-support (3.10.1)
         | 
| 36 | 
            +
                ruby2_keywords (0.0.2)
         | 
| 37 | 
            +
                sinatra (2.1.0)
         | 
| 38 | 
            +
                  mustermann (~> 1.0)
         | 
| 39 | 
            +
                  rack (~> 2.2)
         | 
| 40 | 
            +
                  rack-protection (= 2.1.0)
         | 
| 41 | 
            +
                  tilt (~> 2.0)
         | 
| 31 42 | 
             
                temple (0.8.2)
         | 
| 43 | 
            +
                tilt (2.0.10)
         | 
| 32 44 |  | 
| 33 45 | 
             
            PLATFORMS
         | 
| 34 | 
            -
              x86_64-darwin- | 
| 46 | 
            +
              x86_64-darwin-15
         | 
| 35 47 |  | 
| 36 48 | 
             
            DEPENDENCIES
         | 
| 37 49 | 
             
              rake (~> 13.0)
         | 
| 38 50 | 
             
              rspec (~> 3.0)
         | 
| 51 | 
            +
              sinatra (~> 2.1)
         | 
| 52 | 
            +
              tilt (~> 2.0, >= 2.0.10)
         | 
| 39 53 | 
             
              wlang!
         | 
| 40 54 |  | 
| 41 55 | 
             
            BUNDLED WITH
         | 
| 42 | 
            -
               2.2. | 
| 56 | 
            +
               2.2.1
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,5 +1,7 @@ | |
| 1 1 | 
             
            # WLang
         | 
| 2 2 |  | 
| 3 | 
            +
            
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            WLang is a powerful code generation and templating engine, implemented on top o
         | 
| 4 6 | 
             
            [temple](https://github.com/judofyr/temple) and much inspired by the excellent
         | 
| 5 7 | 
             
            [mustache](http://mustache.github.com/).
         | 
| @@ -64,3 +66,57 @@ WLang already provides a few useful dialects, such as WLang::Html | |
| 64 66 | 
             
            match your needs, it is up to you to define you own dialect for making your
         | 
| 65 67 | 
             
            generation task easy. Have a look at the implementation of WLang's ones, it's
         | 
| 66 68 | 
             
            pretty simple to get started!
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            # Tilt integration
         | 
| 71 | 
            +
             | 
| 72 | 
            +
            WLang has built-in support for [Tilt](https://github.com/rtomayko/tilt) facade to templating engines. In order to use that API:
         | 
| 73 | 
            +
             | 
| 74 | 
            +
            ```ruby
         | 
| 75 | 
            +
            require 'tilt'         # needed in your bundle, not a wlang dependency
         | 
| 76 | 
            +
            require 'wlang'        # loads Tilt support provided Tilt has already been required
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            template = Tilt.new("path/to/a/template.wlang")   # suppose 'Hello ${who}!'
         | 
| 79 | 
            +
            template.render(:who => "world")
         | 
| 80 | 
            +
            # => Hello world!
         | 
| 81 | 
            +
             | 
| 82 | 
            +
            template = Tilt.new("path/to/a/template.wlang", :dialect => Highlighter)
         | 
| 83 | 
            +
            template.render(:who => "world")
         | 
| 84 | 
            +
            # => Hello WORLD!
         | 
| 85 | 
            +
            ```
         | 
| 86 | 
            +
             | 
| 87 | 
            +
            Please note that you should require tilt first, then wlang. Otherwise, you'll have to require `wlang/tilt` explicitely.
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            # Sinatra integration
         | 
| 90 | 
            +
             | 
| 91 | 
            +
            WLang comes bundled with built-in support for [Sinatra](https://github.com/sinatra/sinatra) >= 1.4 (release still in progress). As usual in Sinatra, you can simply invoke wlang as follows:
         | 
| 92 | 
            +
             | 
| 93 | 
            +
            ```ruby
         | 
| 94 | 
            +
            get '/' do
         | 
| 95 | 
            +
              wlang :index, :locals => { ... }
         | 
| 96 | 
            +
            end
         | 
| 97 | 
            +
            ```
         | 
| 98 | 
            +
             | 
| 99 | 
            +
            As wlang encourages logic-less templates, you should always use locals. However, there is specific support for layouts and partials, as the following example demonstrates:
         | 
| 100 | 
            +
             | 
| 101 | 
            +
            ```ruby
         | 
| 102 | 
            +
            get '/' do
         | 
| 103 | 
            +
              wlang :index, :locals => {:who => "world"}
         | 
| 104 | 
            +
            end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
            __END__
         | 
| 107 | 
            +
             | 
| 108 | 
            +
            @@layout
         | 
| 109 | 
            +
              <html>
         | 
| 110 | 
            +
                >{yield}
         | 
| 111 | 
            +
              </html>
         | 
| 112 | 
            +
             | 
| 113 | 
            +
            @@index
         | 
| 114 | 
            +
              Hello from a partial: >{partial}
         | 
| 115 | 
            +
             | 
| 116 | 
            +
            @@partial
         | 
| 117 | 
            +
              yeah, a partial saying hello to '${who}'!
         | 
| 118 | 
            +
             | 
| 119 | 
            +
            Returned body will be (ignoring carriage returns):
         | 
| 120 | 
            +
             | 
| 121 | 
            +
            <html>Hello from a partial: yeah, a partial saying hello to 'world'!</html>
         | 
| 122 | 
            +
            ```
         | 
    
        data/lib/wlang.rb
    CHANGED
    
    | @@ -27,6 +27,14 @@ module WLang | |
| 27 27 | 
             
              end
         | 
| 28 28 | 
             
              module_function :dialect
         | 
| 29 29 |  | 
| 30 | 
            +
              SinatraApp = proc{|arg|
         | 
| 31 | 
            +
                defined?(Sinatra::Base) && Sinatra::Base===arg
         | 
| 32 | 
            +
              }
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              TiltTemplate = proc{|arg|
         | 
| 35 | 
            +
                defined?(Tilt::Template) && Tilt::Template===arg
         | 
| 36 | 
            +
              }
         | 
| 37 | 
            +
             | 
| 30 38 | 
             
            end # module WLang
         | 
| 31 39 | 
             
            require 'wlang/compiler'
         | 
| 32 40 | 
             
            require 'wlang/source'
         | 
| @@ -34,3 +42,4 @@ require 'wlang/template' | |
| 34 42 | 
             
            require 'wlang/dialect'
         | 
| 35 43 | 
             
            require 'wlang/scope'
         | 
| 36 44 | 
             
            require 'wlang/html'
         | 
| 45 | 
            +
            require 'wlang/tilt' if defined?(::Tilt)
         | 
    
        data/lib/wlang/scope.rb
    CHANGED
    
    | @@ -17,6 +17,7 @@ module WLang | |
| 17 17 | 
             
                  case arg
         | 
| 18 18 | 
             
                    when Hash       then ObjectScope.new(arg)
         | 
| 19 19 | 
             
                    when Scope      then arg
         | 
| 20 | 
            +
                    when SinatraApp then SinatraScope.new(arg)
         | 
| 20 21 | 
             
                    when Binding    then BindingScope.new(arg)
         | 
| 21 22 | 
             
                    when Proc       then ProcScope.new(arg)
         | 
| 22 23 | 
             
                    else
         | 
| @@ -102,3 +103,4 @@ require 'wlang/scope/null_scope' | |
| 102 103 | 
             
            require 'wlang/scope/object_scope'
         | 
| 103 104 | 
             
            require 'wlang/scope/binding_scope'
         | 
| 104 105 | 
             
            require 'wlang/scope/proc_scope'
         | 
| 106 | 
            +
            require 'wlang/scope/sinatra_scope'
         | 
| @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            module WLang
         | 
| 2 | 
            +
              class Scope
         | 
| 3 | 
            +
                class SinatraScope < ObjectScope
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  def fetch(key, dialect = nil, unfound = nil)
         | 
| 6 | 
            +
                    find_partial(key, subject) || super
         | 
| 7 | 
            +
                  end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  def inspect
         | 
| 10 | 
            +
                    "SinatraScope"
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
                  alias :to_s :inspect
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                private
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def find_partial(key, app)
         | 
| 17 | 
            +
                    find_internal_partial(key, app) || find_external_partial(key, app)
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def find_internal_partial(key, app)
         | 
| 21 | 
            +
                    return unless app.settings.templates[key]
         | 
| 22 | 
            +
                    app.send(:compile_template, :wlang, key, {}, app.settings.views)
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  def find_external_partial(key, app)
         | 
| 26 | 
            +
                    views = app.settings.views
         | 
| 27 | 
            +
                    find_files(views, key) do |file|
         | 
| 28 | 
            +
                      if engine = Tilt[file]
         | 
| 29 | 
            +
                        tpl = app.template_cache.fetch(file) do
         | 
| 30 | 
            +
                          options = if app.settings.respond_to?(:wlang)
         | 
| 31 | 
            +
                                      app.settings.wlang
         | 
| 32 | 
            +
                                    else
         | 
| 33 | 
            +
                                      {}
         | 
| 34 | 
            +
                                    end
         | 
| 35 | 
            +
                          engine.new(file.to_s, 1, options)
         | 
| 36 | 
            +
                        end
         | 
| 37 | 
            +
                        return tpl
         | 
| 38 | 
            +
                      end
         | 
| 39 | 
            +
                    end
         | 
| 40 | 
            +
                    nil
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  def find_files(folder, name, &bl)
         | 
| 44 | 
            +
                    Path(folder).glob("#{name}.*").each(&bl)
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                end # class SinatraScope
         | 
| 48 | 
            +
              end # class Scope
         | 
| 49 | 
            +
            end # module WLang
         | 
    
        data/lib/wlang/tilt.rb
    ADDED
    
    
| @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            module Tilt
         | 
| 2 | 
            +
              class WLangTemplate < ::Tilt::Template
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                class << self
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  def engine_initialized?
         | 
| 7 | 
            +
                    defined? ::WLang
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def with_options(options)
         | 
| 11 | 
            +
                    Class.new(WLangTemplate).tap{|c| c.default_options = options }
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def default_options=(options)
         | 
| 15 | 
            +
                    @default_options = options
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  def default_options
         | 
| 19 | 
            +
                    @default_options ||= {}
         | 
| 20 | 
            +
                    (superclass.default_options rescue {}).merge(@default_options)
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                def initialize_engine
         | 
| 26 | 
            +
                  require_template_library('wlang')
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                protected
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  def prepare
         | 
| 32 | 
            +
                    opts = self.class.default_options.merge(self.options)
         | 
| 33 | 
            +
                    opts.merge!(:path => file) if file
         | 
| 34 | 
            +
                    @engine = WLang::Template.new(data, opts)
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  def evaluate(scope, locals, &block)
         | 
| 38 | 
            +
                    locals[:yield] = block if block
         | 
| 39 | 
            +
                    @engine.render(scope, locals.empty? ? nil : locals)
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
              register WLangTemplate, 'wlang'
         | 
| 44 | 
            +
            end
         | 
    
        data/lib/wlang/version.rb
    CHANGED
    
    
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            require 'tilt'
         | 
| 2 | 
            +
            require 'wlang/tilt'
         | 
| 3 | 
            +
            describe 'WLang integration with tilt' do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              it 'allows invoking tilt directly' do
         | 
| 6 | 
            +
                Tilt.new(hello_path.to_s).render(:who => "world").should eq("Hello world!")
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              it 'allows specifying the dialect' do
         | 
| 10 | 
            +
                Tilt.new(hello_path.to_s, :dialect => Upcasing).render.should eq("Hello WHO!")
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -1,6 +1,9 @@ | |
| 1 1 | 
             
            require 'path'
         | 
| 2 2 | 
             
            $root_folder ||= Path.backfind('.[Rakefile]')
         | 
| 3 3 |  | 
| 4 | 
            +
            require 'tilt'
         | 
| 5 | 
            +
            require 'sinatra/base'
         | 
| 6 | 
            +
             | 
| 4 7 | 
             
            # Require wlang
         | 
| 5 8 | 
             
            $LOAD_PATH.unshift(($root_folder/:lib).to_s)
         | 
| 6 9 | 
             
            require 'wlang'
         | 
| @@ -53,6 +56,10 @@ module Helpers | |
| 53 56 | 
             
                end
         | 
| 54 57 | 
             
              end
         | 
| 55 58 |  | 
| 59 | 
            +
              def sinatra_app(&block)
         | 
| 60 | 
            +
                Sinatra.new(Sinatra::Base, &block).new!
         | 
| 61 | 
            +
              end
         | 
| 62 | 
            +
             | 
| 56 63 | 
             
            end
         | 
| 57 64 | 
             
            include Helpers
         | 
| 58 65 |  | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            module WLang
         | 
| 3 | 
            +
              class Scope
         | 
| 4 | 
            +
                describe SinatraScope, 'fetch' do
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  let(:app){ 
         | 
| 7 | 
            +
                    sinatra_app do
         | 
| 8 | 
            +
                      set :accessible, "world"
         | 
| 9 | 
            +
                      set :views, fixtures_folder/'templates'
         | 
| 10 | 
            +
                      helpers do
         | 
| 11 | 
            +
                        def accessible; settings.accessible; end
         | 
| 12 | 
            +
                      end
         | 
| 13 | 
            +
                    end
         | 
| 14 | 
            +
                  }
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  let(:scope){ Scope::SinatraScope.new(app) }
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  it 'delegates to helpers correctly' do
         | 
| 19 | 
            +
                    scope.fetch(:accessible).should eq("world")
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  it 'returns Tilt templates on existing views' do
         | 
| 23 | 
            +
                    scope.fetch('hello', app).should be_a(Tilt::Template)
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
            end
         | 
| @@ -10,6 +10,10 @@ module WLang | |
| 10 10 | 
             
                  Scope.coerce(lambda{}).should be_a(Scope::ProcScope)
         | 
| 11 11 | 
             
                end
         | 
| 12 12 |  | 
| 13 | 
            +
                it 'recognizes Sinatra applications' do
         | 
| 14 | 
            +
                  Scope.coerce(sinatra_app).should be_a(Scope::SinatraScope)
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 13 17 | 
             
                it 'falls back to ObjectScope on Hash' do
         | 
| 14 18 | 
             
                  Scope.coerce({}).should be_a(Scope::ObjectScope)
         | 
| 15 19 | 
             
                end
         | 
| @@ -0,0 +1,61 @@ | |
| 1 | 
            +
            require 'tilt'
         | 
| 2 | 
            +
            require 'wlang/tilt'
         | 
| 3 | 
            +
            describe Tilt::WLangTemplate do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              it 'supports basic rendering with no scope no locals' do
         | 
| 6 | 
            +
                template = Tilt::WLangTemplate.new{ "Hello" }
         | 
| 7 | 
            +
                template.render.should eq("Hello")
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              it 'supports a binding scope' do
         | 
| 11 | 
            +
                template = Tilt::WLangTemplate.new{ "Hello ${who}" }
         | 
| 12 | 
            +
                who = "world"
         | 
| 13 | 
            +
                template.render(binding).should eq("Hello world")
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              it 'supports a Hash scope' do
         | 
| 17 | 
            +
                template = Tilt::WLangTemplate.new{ "Hello ${who}" }
         | 
| 18 | 
            +
                scope = {:who => "world"}
         | 
| 19 | 
            +
                template.render(scope).should eq("Hello world")
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              it 'supports both a scope and locals' do
         | 
| 23 | 
            +
                template = Tilt::WLangTemplate.new{ "Hello ${who} and ${who_else}" }
         | 
| 24 | 
            +
                who = "world"
         | 
| 25 | 
            +
                template.render(binding, :who_else => 'wlang').should eq("Hello world and wlang")
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              it 'supports being rendered multiple times' do
         | 
| 29 | 
            +
                template = Tilt::WLangTemplate.new{ "Hello ${i}" }
         | 
| 30 | 
            +
                3.times{|i| template.render(binding).should eq("Hello #{i}") }
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              it 'supports passing a block for yielding' do
         | 
| 34 | 
            +
                template = Tilt::WLangTemplate.new{ "Hello ${yield}" }
         | 
| 35 | 
            +
                template.render{ "world" }.should eq('Hello world')
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              it 'supports expressions on yield' do
         | 
| 39 | 
            +
                template = Tilt::WLangTemplate.new{ "Hello ${yield.upcase}" }
         | 
| 40 | 
            +
                template.render{ "world" }.should eq('Hello WORLD')
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
              it 'passes :path option to the underlying template' do
         | 
| 44 | 
            +
                tpl = Tilt::WLangTemplate.new(hello_path.to_s)
         | 
| 45 | 
            +
                tpl = tpl.send(:prepare)
         | 
| 46 | 
            +
                tpl.should be_a(WLang::Template)
         | 
| 47 | 
            +
                tpl.path.should eq(hello_path.to_s)
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              it 'supports passing a dialect as options' do
         | 
| 51 | 
            +
                template = Tilt::WLangTemplate.new(:dialect => Upcasing){ "Hello ${who}" }
         | 
| 52 | 
            +
                template.render.should eq("Hello WHO")
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              it 'supports options through inheritance' do
         | 
| 56 | 
            +
                tpl_class = Tilt::WLangTemplate.with_options(:dialect => Upcasing)
         | 
| 57 | 
            +
                template  = tpl_class.new{ "Hello ${who}" }
         | 
| 58 | 
            +
                template.render.should eq("Hello WHO")
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            end
         | 
    
        data/wlang.gemspec
    CHANGED
    
    | @@ -21,6 +21,8 @@ Gem::Specification.new do |s| | |
| 21 21 |  | 
| 22 22 | 
             
              s.add_development_dependency("rake", "~> 13.0")
         | 
| 23 23 | 
             
              s.add_development_dependency("rspec", "~> 3.0")
         | 
| 24 | 
            +
              s.add_development_dependency("sinatra", "~> 2.1")
         | 
| 25 | 
            +
              s.add_development_dependency("tilt", "~> 2.0", ">= 2.0.10")
         | 
| 24 26 |  | 
| 25 27 | 
             
              s.add_dependency("citrus", "~> 3.0")
         | 
| 26 28 | 
             
              s.add_dependency("quickl", "~> 0.4.3")
         | 
    
        metadata
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: wlang
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 3.0. | 
| 4 | 
            +
              version: 3.0.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Bernard Lambeau
         | 
| 8 8 | 
             
            - Louis Lambeau
         | 
| 9 | 
            -
            autorequire:
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2021-01-07 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: rake
         | 
| @@ -39,6 +39,40 @@ dependencies: | |
| 39 39 | 
             
                - - "~>"
         | 
| 40 40 | 
             
                  - !ruby/object:Gem::Version
         | 
| 41 41 | 
             
                    version: '3.0'
         | 
| 42 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 43 | 
            +
              name: sinatra
         | 
| 44 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 45 | 
            +
                requirements:
         | 
| 46 | 
            +
                - - "~>"
         | 
| 47 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 48 | 
            +
                    version: '2.1'
         | 
| 49 | 
            +
              type: :development
         | 
| 50 | 
            +
              prerelease: false
         | 
| 51 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 52 | 
            +
                requirements:
         | 
| 53 | 
            +
                - - "~>"
         | 
| 54 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 55 | 
            +
                    version: '2.1'
         | 
| 56 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 57 | 
            +
              name: tilt
         | 
| 58 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 59 | 
            +
                requirements:
         | 
| 60 | 
            +
                - - "~>"
         | 
| 61 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 62 | 
            +
                    version: '2.0'
         | 
| 63 | 
            +
                - - ">="
         | 
| 64 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 65 | 
            +
                    version: 2.0.10
         | 
| 66 | 
            +
              type: :development
         | 
| 67 | 
            +
              prerelease: false
         | 
| 68 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 69 | 
            +
                requirements:
         | 
| 70 | 
            +
                - - "~>"
         | 
| 71 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 72 | 
            +
                    version: '2.0'
         | 
| 73 | 
            +
                - - ">="
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: 2.0.10
         | 
| 42 76 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 43 77 | 
             
              name: citrus
         | 
| 44 78 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -143,9 +177,12 @@ files: | |
| 143 177 | 
             
            - lib/wlang/scope/null_scope.rb
         | 
| 144 178 | 
             
            - lib/wlang/scope/object_scope.rb
         | 
| 145 179 | 
             
            - lib/wlang/scope/proc_scope.rb
         | 
| 180 | 
            +
            - lib/wlang/scope/sinatra_scope.rb
         | 
| 146 181 | 
             
            - lib/wlang/source.rb
         | 
| 147 182 | 
             
            - lib/wlang/source/front_matter.rb
         | 
| 148 183 | 
             
            - lib/wlang/template.rb
         | 
| 184 | 
            +
            - lib/wlang/tilt.rb
         | 
| 185 | 
            +
            - lib/wlang/tilt/wlang_template.rb
         | 
| 149 186 | 
             
            - lib/wlang/version.rb
         | 
| 150 187 | 
             
            - spec/assumptions/test_core.rb
         | 
| 151 188 | 
             
            - spec/fixtures/dialect/foobar.rb
         | 
| @@ -176,6 +213,7 @@ files: | |
| 176 213 | 
             
            - spec/integration/test_examples.rb
         | 
| 177 214 | 
             
            - spec/integration/test_readme.rb
         | 
| 178 215 | 
             
            - spec/integration/test_upcasing.rb
         | 
| 216 | 
            +
            - spec/integration/tilt/test_wlang_template.rb
         | 
| 179 217 | 
             
            - spec/spec_helper.rb
         | 
| 180 218 | 
             
            - spec/test_wlang.rb
         | 
| 181 219 | 
             
            - spec/unit/command/test_install.rb
         | 
| @@ -198,6 +236,7 @@ files: | |
| 198 236 | 
             
            - spec/unit/dialect/test_tag.rb
         | 
| 199 237 | 
             
            - spec/unit/dialect/test_tag_dispatching_name.rb
         | 
| 200 238 | 
             
            - spec/unit/dialect/test_with_scope.rb
         | 
| 239 | 
            +
            - spec/unit/scope/sinatra_scope/test_fetch.rb
         | 
| 201 240 | 
             
            - spec/unit/scope/test_binding_scope.rb
         | 
| 202 241 | 
             
            - spec/unit/scope/test_chain.rb
         | 
| 203 242 | 
             
            - spec/unit/scope/test_coerce.rb
         | 
| @@ -222,13 +261,14 @@ files: | |
| 222 261 | 
             
            - spec/unit/template/test_yaml_front_matter.rb
         | 
| 223 262 | 
             
            - spec/unit/test_assumptions.rb
         | 
| 224 263 | 
             
            - spec/unit/test_scope.rb
         | 
| 264 | 
            +
            - spec/unit/tilt/test_wlang_template.rb
         | 
| 225 265 | 
             
            - tasks/gem.rake
         | 
| 226 266 | 
             
            - tasks/test.rake
         | 
| 227 267 | 
             
            - wlang.gemspec
         | 
| 228 268 | 
             
            homepage: http://github.com/blambeau/wlang
         | 
| 229 269 | 
             
            licenses: []
         | 
| 230 270 | 
             
            metadata: {}
         | 
| 231 | 
            -
            post_install_message:
         | 
| 271 | 
            +
            post_install_message: 
         | 
| 232 272 | 
             
            rdoc_options: []
         | 
| 233 273 | 
             
            require_paths:
         | 
| 234 274 | 
             
            - lib
         | 
| @@ -243,83 +283,86 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 243 283 | 
             
                - !ruby/object:Gem::Version
         | 
| 244 284 | 
             
                  version: '0'
         | 
| 245 285 | 
             
            requirements: []
         | 
| 246 | 
            -
            rubygems_version: 3.1 | 
| 247 | 
            -
            signing_key:
         | 
| 286 | 
            +
            rubygems_version: 3.2.1
         | 
| 287 | 
            +
            signing_key: 
         | 
| 248 288 | 
             
            specification_version: 4
         | 
| 249 289 | 
             
            summary: WLang is a powerful code generation and templating engine
         | 
| 250 290 | 
             
            test_files:
         | 
| 291 | 
            +
            - spec/assumptions/test_core.rb
         | 
| 292 | 
            +
            - spec/fixtures/dialect/foobar.rb
         | 
| 293 | 
            +
            - spec/fixtures/dialect/upcasing.rb
         | 
| 294 | 
            +
            - spec/fixtures/templates/front_matter.wlang
         | 
| 295 | 
            +
            - spec/fixtures/templates/hello.wlang
         | 
| 296 | 
            +
            - spec/fixtures/templates/hello_from_sinatra.wlang
         | 
| 297 | 
            +
            - spec/fixtures/templates/hello_with_data.wlang
         | 
| 298 | 
            +
            - spec/fixtures/templates/hello_with_explicit_locals.wlang
         | 
| 299 | 
            +
            - spec/fixtures/templates/hello_with_partials.wlang
         | 
| 300 | 
            +
            - spec/integration/examples/1-html-intro/1-basics.md
         | 
| 301 | 
            +
            - spec/integration/examples/1-html-intro/2-imperative.md
         | 
| 302 | 
            +
            - spec/integration/examples/1-html-intro/3-partials.md
         | 
| 303 | 
            +
            - spec/integration/examples/1-html-intro/4-recursion.md
         | 
| 304 | 
            +
            - spec/integration/examples/1-html-intro/5-polymorphism.md
         | 
| 305 | 
            +
            - spec/integration/html/test_ampersand.rb
         | 
| 306 | 
            +
            - spec/integration/html/test_bang.rb
         | 
| 307 | 
            +
            - spec/integration/html/test_caret.rb
         | 
| 308 | 
            +
            - spec/integration/html/test_dollar.rb
         | 
| 309 | 
            +
            - spec/integration/html/test_greater.rb
         | 
| 310 | 
            +
            - spec/integration/html/test_modulo.rb
         | 
| 311 | 
            +
            - spec/integration/html/test_plus.rb
         | 
| 312 | 
            +
            - spec/integration/html/test_question.rb
         | 
| 313 | 
            +
            - spec/integration/html/test_sharp.rb
         | 
| 314 | 
            +
            - spec/integration/html/test_slash.rb
         | 
| 315 | 
            +
            - spec/integration/html/test_star.rb
         | 
| 316 | 
            +
            - spec/integration/test_dummy.rb
         | 
| 317 | 
            +
            - spec/integration/test_examples.rb
         | 
| 318 | 
            +
            - spec/integration/test_readme.rb
         | 
| 319 | 
            +
            - spec/integration/test_upcasing.rb
         | 
| 320 | 
            +
            - spec/integration/tilt/test_wlang_template.rb
         | 
| 251 321 | 
             
            - spec/spec_helper.rb
         | 
| 252 | 
            -
            - spec/ | 
| 322 | 
            +
            - spec/test_wlang.rb
         | 
| 323 | 
            +
            - spec/unit/command/test_install.rb
         | 
| 324 | 
            +
            - spec/unit/compiler/autospacing/test_right_strip.rb
         | 
| 325 | 
            +
            - spec/unit/compiler/autospacing/test_unindent.rb
         | 
| 326 | 
            +
            - spec/unit/compiler/test_dialect_enforcer.rb
         | 
| 327 | 
            +
            - spec/unit/compiler/test_grammar.rb
         | 
| 328 | 
            +
            - spec/unit/compiler/test_parser.rb
         | 
| 329 | 
            +
            - spec/unit/compiler/test_proc_call_removal.rb
         | 
| 330 | 
            +
            - spec/unit/compiler/test_static_merger.rb
         | 
| 331 | 
            +
            - spec/unit/compiler/test_strconcat_flattener.rb
         | 
| 332 | 
            +
            - spec/unit/compiler/test_to_ruby_abstraction.rb
         | 
| 333 | 
            +
            - spec/unit/compiler/test_to_ruby_code.rb
         | 
| 334 | 
            +
            - spec/unit/compiler/test_to_ruby_proc.rb
         | 
| 335 | 
            +
            - spec/unit/dialect/test_compile.rb
         | 
| 336 | 
            +
            - spec/unit/dialect/test_context.rb
         | 
| 337 | 
            +
            - spec/unit/dialect/test_evaluate.rb
         | 
| 338 | 
            +
            - spec/unit/dialect/test_new.rb
         | 
| 339 | 
            +
            - spec/unit/dialect/test_render.rb
         | 
| 340 | 
            +
            - spec/unit/dialect/test_tag.rb
         | 
| 341 | 
            +
            - spec/unit/dialect/test_tag_dispatching_name.rb
         | 
| 342 | 
            +
            - spec/unit/dialect/test_with_scope.rb
         | 
| 343 | 
            +
            - spec/unit/scope/sinatra_scope/test_fetch.rb
         | 
| 344 | 
            +
            - spec/unit/scope/test_binding_scope.rb
         | 
| 345 | 
            +
            - spec/unit/scope/test_chain.rb
         | 
| 346 | 
            +
            - spec/unit/scope/test_coerce.rb
         | 
| 347 | 
            +
            - spec/unit/scope/test_null_scope.rb
         | 
| 348 | 
            +
            - spec/unit/scope/test_object_scope.rb
         | 
| 349 | 
            +
            - spec/unit/scope/test_proc_scope.rb
         | 
| 350 | 
            +
            - spec/unit/scope/test_push.rb
         | 
| 253 351 | 
             
            - spec/unit/source/front_matter/test_locals.rb
         | 
| 254 | 
            -
            - spec/unit/source/test_template_content.rb
         | 
| 352 | 
            +
            - spec/unit/source/front_matter/test_template_content.rb
         | 
| 353 | 
            +
            - spec/unit/source/test_locals.rb
         | 
| 255 354 | 
             
            - spec/unit/source/test_path.rb
         | 
| 355 | 
            +
            - spec/unit/source/test_template_content.rb
         | 
| 256 356 | 
             
            - spec/unit/source/test_with_front_matter.rb
         | 
| 257 | 
            -
            - spec/unit/source/test_locals.rb
         | 
| 258 | 
            -
            - spec/unit/test_assumptions.rb
         | 
| 259 357 | 
             
            - spec/unit/template/test_call.rb
         | 
| 260 | 
            -
            - spec/unit/template/ | 
| 261 | 
            -
            - spec/unit/template/test_to_ruby_code.rb
         | 
| 358 | 
            +
            - spec/unit/template/test_call_args_conventions.rb
         | 
| 262 359 | 
             
            - spec/unit/template/test_new.rb
         | 
| 263 360 | 
             
            - spec/unit/template/test_path.rb
         | 
| 264 | 
            -
            - spec/unit/template/test_to_ruby_proc.rb
         | 
| 265 361 | 
             
            - spec/unit/template/test_render.rb
         | 
| 362 | 
            +
            - spec/unit/template/test_to_ast.rb
         | 
| 363 | 
            +
            - spec/unit/template/test_to_ruby_code.rb
         | 
| 364 | 
            +
            - spec/unit/template/test_to_ruby_proc.rb
         | 
| 266 365 | 
             
            - spec/unit/template/test_yaml_front_matter.rb
         | 
| 267 | 
            -
            - spec/unit/ | 
| 268 | 
            -
            - spec/unit/scope/test_chain.rb
         | 
| 269 | 
            -
            - spec/unit/scope/test_push.rb
         | 
| 270 | 
            -
            - spec/unit/scope/test_object_scope.rb
         | 
| 271 | 
            -
            - spec/unit/scope/test_binding_scope.rb
         | 
| 272 | 
            -
            - spec/unit/scope/test_proc_scope.rb
         | 
| 273 | 
            -
            - spec/unit/scope/test_null_scope.rb
         | 
| 274 | 
            -
            - spec/unit/scope/test_coerce.rb
         | 
| 366 | 
            +
            - spec/unit/test_assumptions.rb
         | 
| 275 367 | 
             
            - spec/unit/test_scope.rb
         | 
| 276 | 
            -
            - spec/unit/ | 
| 277 | 
            -
            - spec/unit/dialect/test_new.rb
         | 
| 278 | 
            -
            - spec/unit/dialect/test_render.rb
         | 
| 279 | 
            -
            - spec/unit/dialect/test_context.rb
         | 
| 280 | 
            -
            - spec/unit/dialect/test_tag.rb
         | 
| 281 | 
            -
            - spec/unit/dialect/test_evaluate.rb
         | 
| 282 | 
            -
            - spec/unit/dialect/test_compile.rb
         | 
| 283 | 
            -
            - spec/unit/dialect/test_with_scope.rb
         | 
| 284 | 
            -
            - spec/unit/dialect/test_tag_dispatching_name.rb
         | 
| 285 | 
            -
            - spec/unit/compiler/test_to_ruby_code.rb
         | 
| 286 | 
            -
            - spec/unit/compiler/test_proc_call_removal.rb
         | 
| 287 | 
            -
            - spec/unit/compiler/test_to_ruby_proc.rb
         | 
| 288 | 
            -
            - spec/unit/compiler/test_strconcat_flattener.rb
         | 
| 289 | 
            -
            - spec/unit/compiler/test_dialect_enforcer.rb
         | 
| 290 | 
            -
            - spec/unit/compiler/test_to_ruby_abstraction.rb
         | 
| 291 | 
            -
            - spec/unit/compiler/test_grammar.rb
         | 
| 292 | 
            -
            - spec/unit/compiler/test_parser.rb
         | 
| 293 | 
            -
            - spec/unit/compiler/autospacing/test_right_strip.rb
         | 
| 294 | 
            -
            - spec/unit/compiler/autospacing/test_unindent.rb
         | 
| 295 | 
            -
            - spec/unit/compiler/test_static_merger.rb
         | 
| 296 | 
            -
            - spec/integration/test_examples.rb
         | 
| 297 | 
            -
            - spec/integration/test_readme.rb
         | 
| 298 | 
            -
            - spec/integration/html/test_greater.rb
         | 
| 299 | 
            -
            - spec/integration/html/test_ampersand.rb
         | 
| 300 | 
            -
            - spec/integration/html/test_bang.rb
         | 
| 301 | 
            -
            - spec/integration/html/test_slash.rb
         | 
| 302 | 
            -
            - spec/integration/html/test_sharp.rb
         | 
| 303 | 
            -
            - spec/integration/html/test_star.rb
         | 
| 304 | 
            -
            - spec/integration/html/test_caret.rb
         | 
| 305 | 
            -
            - spec/integration/html/test_question.rb
         | 
| 306 | 
            -
            - spec/integration/html/test_modulo.rb
         | 
| 307 | 
            -
            - spec/integration/html/test_dollar.rb
         | 
| 308 | 
            -
            - spec/integration/html/test_plus.rb
         | 
| 309 | 
            -
            - spec/integration/test_dummy.rb
         | 
| 310 | 
            -
            - spec/integration/test_upcasing.rb
         | 
| 311 | 
            -
            - spec/integration/examples/1-html-intro/5-polymorphism.md
         | 
| 312 | 
            -
            - spec/integration/examples/1-html-intro/2-imperative.md
         | 
| 313 | 
            -
            - spec/integration/examples/1-html-intro/1-basics.md
         | 
| 314 | 
            -
            - spec/integration/examples/1-html-intro/3-partials.md
         | 
| 315 | 
            -
            - spec/integration/examples/1-html-intro/4-recursion.md
         | 
| 316 | 
            -
            - spec/assumptions/test_core.rb
         | 
| 317 | 
            -
            - spec/test_wlang.rb
         | 
| 318 | 
            -
            - spec/fixtures/templates/hello_with_explicit_locals.wlang
         | 
| 319 | 
            -
            - spec/fixtures/templates/hello_from_sinatra.wlang
         | 
| 320 | 
            -
            - spec/fixtures/templates/front_matter.wlang
         | 
| 321 | 
            -
            - spec/fixtures/templates/hello.wlang
         | 
| 322 | 
            -
            - spec/fixtures/templates/hello_with_partials.wlang
         | 
| 323 | 
            -
            - spec/fixtures/templates/hello_with_data.wlang
         | 
| 324 | 
            -
            - spec/fixtures/dialect/foobar.rb
         | 
| 325 | 
            -
            - spec/fixtures/dialect/upcasing.rb
         | 
| 368 | 
            +
            - spec/unit/tilt/test_wlang_template.rb
         |