wlang 2.3.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c13dc41782e57a6c997a991bfd683be1e9ede7887694126d724a7436203bf4f6
4
+ data.tar.gz: 9043c388c6a3326e0b2fdd28fe2b2eef7ac88933b18c6d6434d5c38c5fee2ccc
5
+ SHA512:
6
+ metadata.gz: 283d2695c3c096d80806894e376bbc18c6e170a057092ef149a625857c910ae00c9f8f3e00e8f31c655788a6ea148b3c98718bc3bad32a8caeff283609e47ced
7
+ data.tar.gz: 9e0427a186128ef78959ca01906baffe296b0730f7cb6f052883f0d3a12b0c5faf7ebc49cc917c8ec399adee03e30030d2e012fbcfa1f09db561f51cd6bff45b
@@ -1,10 +1,8 @@
1
- # 2.3.1 / 2014-10-23
1
+ # 3.0.0 / 2020-12-29
2
2
 
3
- * Fix bug (empty? not defined) when using an object as sinatra's locals
4
-
5
- # 2.3.0 / 2014-08-04
6
-
7
- * Allowed Citrus to 3.0
3
+ * Clean project to use a standard ruby-2.7 stack
4
+ * Upgrade citrus to 3.x
5
+ * Remove support for sinatra and tilt
8
6
 
9
7
  # 2.2.4 / 2014-07-29
10
8
 
data/Gemfile CHANGED
@@ -1,22 +1,2 @@
1
1
  source 'http://rubygems.org'
2
-
3
- group :runtime do
4
- gem "citrus", "~> 3.0"
5
- gem "temple", "~> 0.6"
6
- gem "quickl", "~> 0.4.3"
7
- gem "path", "~> 1.3"
8
- gem "backports", "~> 2.6"
9
- end
10
-
11
- group :extra do
12
- gem "awesome_print", "~> 1.0.2"
13
- end
14
-
15
- group :development do
16
- gem "tilt", "~> 1.3"
17
- gem "rake", "~> 0.9.2"
18
- gem "bundler", "~> 1.0"
19
- gem "rspec", "~> 2.10.0"
20
- gem "sinatra", ">= 1.4"
21
- gem "rack-test", "~> 0.6"
22
- end
2
+ gemspec
@@ -1,46 +1,42 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ wlang (3.0.0)
5
+ citrus (~> 3.0)
6
+ path (~> 2.0)
7
+ quickl (~> 0.4.3)
8
+ temple (~> 0.6)
9
+
1
10
  GEM
2
11
  remote: http://rubygems.org/
3
12
  specs:
4
- awesome_print (1.0.2)
5
- backports (2.8.2)
6
- citrus (3.0.1)
7
- diff-lcs (1.1.3)
8
- path (1.3.1)
13
+ citrus (3.0.2)
14
+ diff-lcs (1.4.4)
15
+ path (2.0.1)
9
16
  quickl (0.4.3)
10
- rack (1.5.2)
11
- rack-protection (1.5.0)
12
- rack
13
- rack-test (0.6.2)
14
- rack (>= 1.0)
15
- rake (0.9.6)
16
- rspec (2.10.0)
17
- rspec-core (~> 2.10.0)
18
- rspec-expectations (~> 2.10.0)
19
- rspec-mocks (~> 2.10.0)
20
- rspec-core (2.10.1)
21
- rspec-expectations (2.10.0)
22
- diff-lcs (~> 1.1.3)
23
- rspec-mocks (2.10.1)
24
- sinatra (1.4.2)
25
- rack (~> 1.5, >= 1.5.2)
26
- rack-protection (~> 1.4)
27
- tilt (~> 1.3, >= 1.3.4)
28
- temple (0.6.5)
29
- tilt (1.3.7)
17
+ rake (13.0.3)
18
+ rspec (3.10.0)
19
+ rspec-core (~> 3.10.0)
20
+ rspec-expectations (~> 3.10.0)
21
+ rspec-mocks (~> 3.10.0)
22
+ rspec-core (3.10.1)
23
+ rspec-support (~> 3.10.0)
24
+ rspec-expectations (3.10.1)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.10.0)
27
+ rspec-mocks (3.10.1)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-support (3.10.1)
31
+ temple (0.8.2)
30
32
 
31
33
  PLATFORMS
32
- ruby
34
+ x86_64-darwin-18
33
35
 
34
36
  DEPENDENCIES
35
- awesome_print (~> 1.0.2)
36
- backports (~> 2.6)
37
- bundler (~> 1.0)
38
- citrus (~> 3.0)
39
- path (~> 1.3)
40
- quickl (~> 0.4.3)
41
- rack-test (~> 0.6)
42
- rake (~> 0.9.2)
43
- rspec (~> 2.10.0)
44
- sinatra (>= 1.4)
45
- temple (~> 0.6)
46
- tilt (~> 1.3)
37
+ rake (~> 13.0)
38
+ rspec (~> 3.0)
39
+ wlang!
40
+
41
+ BUNDLED WITH
42
+ 2.2.2
data/LICENCE.md CHANGED
@@ -1,22 +1,20 @@
1
- # The MIT Licence
1
+ Copyright (c) 2012-2021 - Bernard Lambeau, Louis Lambeau
2
2
 
3
- Copyright (c) 2012 - Bernard Lambeau, Louis Lambeau
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
4
10
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
12
13
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,40 +1,48 @@
1
1
  # WLang
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/blambeau/wlang.png?branch=wlang2)](http://travis-ci.org/blambeau/wlang)
4
-
5
- WLang is a powerful code generation and templating engine, implemented on top of [temple](https://github.com/judofyr/temple) and much inspired by the excellent [mustache](http://mustache.github.com/).
3
+ WLang is a powerful code generation and templating engine, implemented on top o
4
+ [temple](https://github.com/judofyr/temple) and much inspired by the excellent
5
+ [mustache](http://mustache.github.com/).
6
6
 
7
7
  ## Links
8
8
 
9
9
  * http://github.com/blambeau/wlang
10
- * http://blambeau.github.com/wlang
11
10
  * http://rubygems.org/gems/wlang
12
11
  * http://revision-zero.org/wlang
13
12
 
14
13
  ## Features
15
14
 
16
15
  * Tunable templating engine. You can define your own tags, and their behavior.
17
- * Powerful logic-less HTML concretization to render web pages à la Mustache with extra.
16
+ * Powerful logic-less HTML concretization to render web pages à la Mustache
17
+ with extra.
18
18
  * Compiled templates for speedy generation.
19
- * [Tilt](https://github.com/rtomayko/tilt) and [Sinatra](https://github.com/sinatra/sinatra) integration.
20
19
 
21
- WLang 2.0 also has a few remaining issues.
20
+ WLang 3.0 also has a few remaining issues.
22
21
 
23
- * It does not support rubinius so far, due to an incompatibility with the Citrus parser generator.
24
- * It has some issues with spacing; not a big issue for HTML rendering but might prevent certain generation tasks.
22
+ * It has some issues with spacing; not a big issue for HTML rendering but might
23
+ prevent certain generation tasks.
25
24
 
26
25
  ## Tunable templating engine
27
26
 
28
- WLang is a templating engine, written in ruby. In that, it is similar to ERB, Mustache and the like:
27
+ WLang is a templating engine, written in ruby. In that, it is similar to ERB,
28
+ Mustache and the like:
29
29
 
30
30
  ```ruby
31
31
  WLang::Html.render 'Hello to ${who}!', who: 'you & the world'
32
32
  # => "Hello to you &amp; the world!"
33
33
  ```
34
34
 
35
- To output HTML pages, WLang does not provides you with killer features or extraordinary shortcus. It supports escaping, as shown above, but many other templating engines do. For such HTML tasks, WLang does a pretty good job but many other engines perform faster and have nicer features. See the examples folder that documents WLang::Html.
35
+ To output HTML pages, WLang does not provides you with killer features or
36
+ extraordinary shortcus. It supports escaping, as shown above, but many other
37
+ templating engines do. For such HTML tasks, WLang does a pretty good job but
38
+ many other engines perform faster and have nicer features. See the examples
39
+ folder that documents WLang::Html.
36
40
 
37
- WLang is designed to help you for other uses cases, user-defined ones in particular, such as generating code or whatever text generation task for which other engines quickly become inappropriate. WLang helps there because it allows you to create your own _dialect_, that is, you can define your own tags and their behavior. For instance,
41
+ WLang is designed to help you for other uses cases, user-defined ones in
42
+ particular, such as generating code or whatever text generation task for
43
+ which other engines quickly become inappropriate. WLang helps there because
44
+ it allows you to create your own _dialect_, that is, you can define your own
45
+ tags and their behavior. For instance,
38
46
 
39
47
  ```ruby
40
48
  class Highlighter < WLang::Dialect
@@ -47,58 +55,12 @@ class Highlighter < WLang::Dialect
47
55
 
48
56
  tag '$', :highlight
49
57
  end
50
- Highlighter.render('Hello ${who}!'), who: 'you & the world'
58
+ Highlighter.render('Hello ${who}!', who: 'you & the world')
51
59
  # => "Hello YOU & THE WORLD !"
52
60
  ```
53
61
 
54
- WLang already provides a few useful dialects, such as WLang::Html (inspired by Mustache but a bit more powerful in my opinion). If they don't match your needs, it is up to you to define you own dialect for making your generation task easy. Have a look at the implementation of WLang's ones, it's pretty simple to get started!
55
-
56
- # Tilt integration
57
-
58
- WLang has built-in support for [Tilt](https://github.com/rtomayko/tilt) facade to templating engines. In order to use that API:
59
-
60
- ```ruby
61
- require 'tilt' # needed in your bundle, not a wlang dependency
62
- require 'wlang' # loads Tilt support provided Tilt has already been required
63
-
64
- template = Tilt.new("path/to/a/template.wlang") # suppose 'Hello ${who}!'
65
- template.render(:who => "world")
66
- # => Hello world!
67
-
68
- template = Tilt.new("path/to/a/template.wlang", :dialect => Highlighter)
69
- template.render(:who => "world")
70
- # => Hello WORLD!
71
- ```
72
-
73
- Please note that you should require tilt first, then wlang. Otherwise, you'll have to require `wlang/tilt` explicitely.
74
-
75
- # Sinatra integration
76
-
77
- 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:
78
-
79
- get '/' do
80
- wlang :index, :locals => { ... }
81
- end
82
-
83
- 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:
84
-
85
- get '/' do
86
- wlang :index, :locals => {:who => "world"}
87
- end
88
-
89
- __END__
90
-
91
- @@layout
92
- <html>
93
- >{yield}
94
- </html>
95
-
96
- @@index
97
- Hello from a partial: >{partial}
98
-
99
- @@partial
100
- yeah, a partial saying hello to '${who}'!
101
-
102
- Returned body will be (ignoring carriage returns):
103
-
104
- <html>Hello from a partial: yeah, a partial saying hello to 'world'!</html>
62
+ WLang already provides a few useful dialects, such as WLang::Html
63
+ (inspired by Mustache but a bit more powerful in my opinion). If they don't
64
+ match your needs, it is up to you to define you own dialect for making your
65
+ generation task easy. Have a look at the implementation of WLang's ones, it's
66
+ pretty simple to get started!
@@ -27,14 +27,6 @@ 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
-
38
30
  end # module WLang
39
31
  require 'wlang/compiler'
40
32
  require 'wlang/source'
@@ -42,4 +34,3 @@ require 'wlang/template'
42
34
  require 'wlang/dialect'
43
35
  require 'wlang/scope'
44
36
  require 'wlang/html'
45
- require 'wlang/tilt' if defined?(::Tilt)
@@ -2,7 +2,7 @@ grammar WLang::Grammar
2
2
 
3
3
  rule template
4
4
  (strconcat !.){
5
- [:template, [:fn, captures[:strconcat].first.value]]
5
+ [:template, [:fn, capture(:strconcat).value]]
6
6
  }
7
7
  end
8
8
 
@@ -29,15 +29,15 @@ grammar WLang::Grammar
29
29
  rule block
30
30
  (fn_start strconcat fn_stop){
31
31
  [:strconcat,
32
- [:static, captures[:fn_start].first.to_s],
33
- captures[:strconcat].first.value,
34
- [:static, captures[:fn_stop].first.to_s]]
32
+ [:static, capture(:fn_start).to_s],
33
+ capture(:strconcat).value,
34
+ [:static, capture(:fn_stop).to_s]]
35
35
  }
36
36
  end
37
37
 
38
38
  rule wlang
39
39
  (symbols functions){
40
- [:wlang, captures[:symbols].first.to_s] + captures[:functions].first.value
40
+ [:wlang, capture(:symbols).to_s] + capture(:functions).value
41
41
  }
42
42
  end
43
43
 
@@ -47,7 +47,7 @@ grammar WLang::Grammar
47
47
 
48
48
  rule function
49
49
  (fn_start strconcat fn_stop){
50
- captures[:strconcat].first.value
50
+ capture(:strconcat).value
51
51
  }
52
52
  end
53
53
 
@@ -161,7 +161,7 @@ module WLang
161
161
 
162
162
  # Returns the current rendering scope.
163
163
  def scope
164
- @scope || Scope.null
164
+ @scope ||= Scope.null
165
165
  end
166
166
 
167
167
  # Yields the block with a scope branched with a sub-scope `x`.
@@ -2,4 +2,3 @@ require "citrus"
2
2
  require "temple"
3
3
  require "quickl"
4
4
  require "path"
5
- require 'backports' if RUBY_VERSION < "1.9"
@@ -17,7 +17,6 @@ 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)
21
20
  when Binding then BindingScope.new(arg)
22
21
  when Proc then ProcScope.new(arg)
23
22
  else
@@ -103,4 +102,3 @@ require 'wlang/scope/null_scope'
103
102
  require 'wlang/scope/object_scope'
104
103
  require 'wlang/scope/binding_scope'
105
104
  require 'wlang/scope/proc_scope'
106
- require 'wlang/scope/sinatra_scope'
@@ -48,29 +48,25 @@ module WLang
48
48
  scope, buffer = call_args_conventions(args)
49
49
  dialect_instance.dup.render compiled, scope, buffer
50
50
  end
51
- alias :render :call
52
-
53
- private
54
51
 
55
- attr_reader :source, :compiled, :dialect_instance
52
+ alias :render :call
56
53
 
57
- def yaml_front_matter?
58
- opt = options[:yaml_front_matter]
59
- opt.nil? or opt
60
- end
54
+ attr_reader :source, :compiled, :dialect_instance
61
55
 
62
- def call_args_conventions(args)
63
- # Ensure a buffer as lat argument
64
- args << '' unless args.last.respond_to?(:<<)
65
- buffer = args.pop
56
+ private
66
57
 
67
- # puts locals if any
68
- args << self.locals unless self.locals.empty?
58
+ def yaml_front_matter?
59
+ opt = options[:yaml_front_matter]
60
+ opt.nil? or opt
61
+ end
69
62
 
70
- # create a scope now
71
- scope = WLang::Scope.chain(args)
72
- [scope, buffer]
73
- end
63
+ def call_args_conventions(args)
64
+ args << '' unless args.last.respond_to?(:<<)
65
+ buffer = args.pop
66
+ args << self.locals unless self.locals.empty?
67
+ scope = WLang::Scope.chain(args)
68
+ [scope, buffer]
69
+ end
74
70
 
75
71
  end # class Template
76
72
  end # module WLang
@@ -1,9 +1,9 @@
1
1
  module WLang
2
2
  module Version
3
3
 
4
- MAJOR = 2
5
- MINOR = 3
6
- TINY = 1
4
+ MAJOR = 3
5
+ MINOR = 0
6
+ TINY = 0
7
7
 
8
8
  def self.to_s
9
9
  [ MAJOR, MINOR, TINY ].join('.')
@@ -0,0 +1,4 @@
1
+ ---
2
+ foo: bar
3
+ ---
4
+ Hello ${who} ${foo}!
@@ -1,9 +1,6 @@
1
1
  require 'path'
2
2
  $root_folder ||= Path.backfind('.[Rakefile]')
3
3
 
4
- require 'tilt'
5
- require 'sinatra/base'
6
-
7
4
  # Require wlang
8
5
  $LOAD_PATH.unshift(($root_folder/:lib).to_s)
9
6
  require 'wlang'
@@ -56,10 +53,6 @@ module Helpers
56
53
  end
57
54
  end
58
55
 
59
- def sinatra_app(&block)
60
- Sinatra.new(Sinatra::Base, &block).new!
61
- end
62
-
63
56
  end
64
57
  include Helpers
65
58