rehab 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/Guardfile +10 -0
- data/LICENSE +20 -0
- data/README.md +83 -0
- data/Rakefile +1 -0
- data/lib/rehab.rb +13 -0
- data/lib/rehab/control.rb +7 -0
- data/lib/rehab/do_filter.rb +10 -0
- data/lib/rehab/engine.rb +16 -0
- data/lib/rehab/file_provider.rb +9 -0
- data/lib/rehab/filter.rb +4 -0
- data/lib/rehab/interpolation.rb +29 -0
- data/lib/rehab/missing_partial_error.rb +17 -0
- data/lib/rehab/parser.rb +66 -0
- data/lib/rehab/template.rb +15 -0
- data/lib/rehab/version.rb +3 -0
- data/rehab.gemspec +29 -0
- data/sample.html +29 -0
- data/spec/.DS_Store +0 -0
- data/spec/integration_spec.rb +235 -0
- data/todo.html +9 -0
- metadata +167 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b4338df2ba361c5df88f5b3ac91945490e0c53fb
|
4
|
+
data.tar.gz: 9d964f493fdf127786326b50a8bc1cb2c011e856
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ef4e821a5cc2068ddbb75450e161b94021c4098d1a6c07000e614a3bd43bebed082de43d36945bbff4af3dec0a07a597df93f3cfd0b7d67b8a93ece57fe21294
|
7
|
+
data.tar.gz: 5de144c4bf03350e74949497ee15e468563e128108d06a8596e712fd1af90ae0d569f971a509049f8cde2691d3b08c0462f9a3a180afcc9cda0621c01f6443cd
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :rspec, cli: "--color", all_on_start: true, bundler: false do
|
5
|
+
watch('spec/spec_helper.rb') { "spec" }
|
6
|
+
watch(%r{^spec/.+_spec\.rb$})
|
7
|
+
watch(%r{^rehab/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
8
|
+
watch(%r{(.+)\.rb$}) { |m| "spec/integration_spec.rb" }
|
9
|
+
end
|
10
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Shane Kuester
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
Rehab
|
2
|
+
=====
|
3
|
+
|
4
|
+
Simple, Portable Template Language.
|
5
|
+
|
6
|
+
|
7
|
+
Installation
|
8
|
+
------------
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'rehab'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rehab
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
Usage
|
24
|
+
-----
|
25
|
+
You can use Rehab like any tilt-like template.
|
26
|
+
|
27
|
+
Rehab::Template.new(options) { "template_source" }.render(scope)
|
28
|
+
|
29
|
+
See `spec/integration_spec.rb` and `sample.html` for more documentation.
|
30
|
+
|
31
|
+
### Options
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
# OPTIONAL
|
35
|
+
options[:file_provider] =>
|
36
|
+
# an object with a .call method that returns file content from a path string
|
37
|
+
->(path){ File.read(path) }
|
38
|
+
```
|
39
|
+
|
40
|
+
|
41
|
+
Syntax Overview
|
42
|
+
---------------
|
43
|
+
The goal is to have very little syntax, other than plain ruby and a couple conveniences for templating.
|
44
|
+
It may be harnessing the full power of ruby, but remember: just because you *can* doesn't mean you *should*.
|
45
|
+
|
46
|
+
Interpolation:
|
47
|
+
|
48
|
+
<p>{{ greeting }} World!<p>
|
49
|
+
|
50
|
+
Control Flow:
|
51
|
+
|
52
|
+
# if greeting.empty?
|
53
|
+
<p>I have nothing to say<p>
|
54
|
+
# end
|
55
|
+
|
56
|
+
Block:
|
57
|
+
|
58
|
+
# 3.times.do |n|
|
59
|
+
<p>{{ n }}. Why didn't I use an ordered list?</p>
|
60
|
+
# end
|
61
|
+
|
62
|
+
Optional "Short" Block (without the 'Do'):
|
63
|
+
|
64
|
+
# 3.times
|
65
|
+
<blink>Click Me!<blink>
|
66
|
+
# end
|
67
|
+
|
68
|
+
Include partial:
|
69
|
+
|
70
|
+
# include my_partial.html
|
71
|
+
|
72
|
+
Include partial for each item in a collection:
|
73
|
+
|
74
|
+
# include awesome-post.html for post in posts
|
75
|
+
|
76
|
+
|
77
|
+
------
|
78
|
+
|
79
|
+
|
80
|
+
Future Plans
|
81
|
+
============
|
82
|
+
* It would be awesome to have an implementation not tied to Ruby, but... Ruby is pretty.
|
83
|
+
* Implement simple filter syntax, see todo.html
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/rehab.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'temple'
|
2
|
+
require 'tilt'
|
3
|
+
|
4
|
+
require 'rehab/file_provider'
|
5
|
+
require 'rehab/filter'
|
6
|
+
require 'rehab/interpolation'
|
7
|
+
require 'rehab/control'
|
8
|
+
require 'rehab/do_filter'
|
9
|
+
require 'rehab/parser'
|
10
|
+
require 'rehab/missing_partial_error'
|
11
|
+
|
12
|
+
require 'rehab/engine'
|
13
|
+
require 'rehab/template'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Rehab
|
2
|
+
class DoFilter < Filter
|
3
|
+
BLOCK_REGEX = /(\A(if|unless|else|elsif|when|begin|rescue|ensure|case|end)\b)|do\s*(\|[^\|]*\|\s*)?\Z/
|
4
|
+
|
5
|
+
def on_rehab_control(code)
|
6
|
+
code = code + ' do' unless code =~ BLOCK_REGEX
|
7
|
+
[:rehab, :control, code]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/lib/rehab/engine.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Rehab
|
2
|
+
class Engine < Temple::Engine
|
3
|
+
|
4
|
+
use Rehab::Parser, :file_provider
|
5
|
+
|
6
|
+
use Rehab::Interpolation
|
7
|
+
use Rehab::DoFilter
|
8
|
+
use Rehab::Control
|
9
|
+
|
10
|
+
filter :MultiFlattener
|
11
|
+
filter :StaticMerger
|
12
|
+
filter :DynamicInliner
|
13
|
+
|
14
|
+
generator :ArrayBuffer
|
15
|
+
end
|
16
|
+
end
|
data/lib/rehab/filter.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Rehab
|
2
|
+
# inline like: {{ foo }}
|
3
|
+
class Interpolation < Filter
|
4
|
+
|
5
|
+
def on_rehab_interpolate(string)
|
6
|
+
block = [:multi]
|
7
|
+
begin
|
8
|
+
case string
|
9
|
+
when /\{\{/m
|
10
|
+
block << [:static, $`]
|
11
|
+
exp, string = parse_expression $'
|
12
|
+
block << [:dynamic, exp]
|
13
|
+
else
|
14
|
+
block << [:static, string]
|
15
|
+
string = ""
|
16
|
+
end
|
17
|
+
end until string.empty?
|
18
|
+
block
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
|
24
|
+
def parse_expression(string)
|
25
|
+
/\}\}/m.match(string)
|
26
|
+
[$`, $']
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/rehab/parser.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
class Rehab::Parser < Temple::Parser
|
2
|
+
attr_reader :source, :out, :line
|
3
|
+
|
4
|
+
|
5
|
+
define_options :file_provider
|
6
|
+
|
7
|
+
|
8
|
+
def call(source)
|
9
|
+
@lines = source.lines
|
10
|
+
@out = [:multi]
|
11
|
+
parse_line while next_line
|
12
|
+
out
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
|
19
|
+
def next_line
|
20
|
+
@line = @lines.shift
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
INCLUDE = /\A\s*#\s*(include)\s*(\S*)\s?(.*)?/
|
25
|
+
CONTROL = /\A\s*#\s*(.*)$/
|
26
|
+
EXPRESSION = /\{\{/m
|
27
|
+
def parse_line
|
28
|
+
case @line
|
29
|
+
when INCLUDE
|
30
|
+
out << parse_include($2, $3)
|
31
|
+
when CONTROL
|
32
|
+
out << [:rehab, :control, $1]
|
33
|
+
when EXPRESSION
|
34
|
+
out << [:rehab, :interpolate, @line]
|
35
|
+
else
|
36
|
+
out << [:static, @line]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def parse_include(path, control = '')
|
42
|
+
if control.empty?
|
43
|
+
parse_file_content(path)
|
44
|
+
else
|
45
|
+
parse_include_with_control(path, control)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def parse_file_content(path)
|
51
|
+
included_content = file_provider.call(path)
|
52
|
+
self.class.new.call(included_content)
|
53
|
+
end
|
54
|
+
|
55
|
+
def file_provider
|
56
|
+
options[:file_provider] || Rehab::FileProvider
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
def parse_include_with_control(path, control)
|
61
|
+
section = [:multi]
|
62
|
+
section << [:code, control]
|
63
|
+
section << parse_file_content(path)
|
64
|
+
section << [:code, 'end']
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# usage: Rehab::Template.new(options) { source }.render(scope)
|
2
|
+
module Rehab
|
3
|
+
class Template
|
4
|
+
attr_reader :tilt, :source
|
5
|
+
|
6
|
+
def initialize(opts = {})
|
7
|
+
@source = yield
|
8
|
+
@tilt = Temple::Templates::Tilt(Rehab::Engine, opts).new { source }
|
9
|
+
end
|
10
|
+
|
11
|
+
def render(scope)
|
12
|
+
tilt.render(scope)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/rehab.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rehab/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rehab"
|
8
|
+
spec.version = Rehab::VERSION
|
9
|
+
spec.license = "MIT"
|
10
|
+
spec.authors = ["Shane Kuester"]
|
11
|
+
spec.email = ["shout@shanekuester.com"]
|
12
|
+
spec.homepage = "https://github.com/skuester/rehab"
|
13
|
+
spec.summary = %q{Simple, portable template language}
|
14
|
+
# spec.description = %q{Simple, portable template language}
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'tilt'
|
22
|
+
spec.add_dependency 'temple'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'rspec'
|
27
|
+
spec.add_development_dependency 'guard'
|
28
|
+
spec.add_development_dependency 'guard-rspec'
|
29
|
+
end
|
data/sample.html
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
<html>
|
2
|
+
<body>
|
3
|
+
# include header.html
|
4
|
+
|
5
|
+
|
6
|
+
# if posts.empty?
|
7
|
+
<p>No posts yet</p>
|
8
|
+
# end
|
9
|
+
|
10
|
+
|
11
|
+
# for post in posts <!-- ignore section if posts missing or null -->
|
12
|
+
<h1>{{ post.title }}</h1>
|
13
|
+
<!-- alternative -->
|
14
|
+
<p>{{ post.author_email || 'No Email' }}</p>
|
15
|
+
<p>{{ post.content }}</p>
|
16
|
+
# end
|
17
|
+
|
18
|
+
<!-- ruby blocks -->
|
19
|
+
# 3.times do |n|
|
20
|
+
<h1>Hello World {{ n }}</h1>
|
21
|
+
# end
|
22
|
+
|
23
|
+
<!-- include partial for collection -->
|
24
|
+
# include partial.html for post in posts
|
25
|
+
|
26
|
+
|
27
|
+
# include footer.html
|
28
|
+
</body>
|
29
|
+
</html>
|
data/spec/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,235 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require_relative "../lib/rehab"
|
3
|
+
|
4
|
+
describe Rehab do
|
5
|
+
def template(src, opts = {})
|
6
|
+
Rehab::Template.new(opts) { src }.render(scope)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "interpolation" do
|
10
|
+
let(:scope) do
|
11
|
+
OpenStruct.new(
|
12
|
+
item: OpenStruct.new(greet: 'World'),
|
13
|
+
awesome: false
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
it "puts a variable from scope" do
|
19
|
+
src = 'Hello {{ item.greet }} and {{ item.greet }}'
|
20
|
+
out = 'Hello World and World'
|
21
|
+
expect(template src).to eq out
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
it "renders multiple lines" do
|
26
|
+
src = <<-EOF
|
27
|
+
Hello {{ item.greet }}
|
28
|
+
Hello {{ item.greet }}
|
29
|
+
EOF
|
30
|
+
|
31
|
+
out = <<-EOF
|
32
|
+
Hello World
|
33
|
+
Hello World
|
34
|
+
EOF
|
35
|
+
expect(template src).to eq out
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
it "doesn't care about white space" do
|
40
|
+
src = 'Hello {{item.greet }}'
|
41
|
+
out = 'Hello World'
|
42
|
+
expect(template src).to eq out
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
it "is a plain ruby expression" do
|
47
|
+
src = "You are so {{ awesome ? 'Awesome' : 'Meh' }}"
|
48
|
+
out = "You are so Meh"
|
49
|
+
expect(template src).to eq out
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
describe "control flow" do
|
57
|
+
let(:scope) do
|
58
|
+
OpenStruct.new(
|
59
|
+
item: OpenStruct.new(greet: 'World'),
|
60
|
+
true_condition: true,
|
61
|
+
false_condition: false
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
it "renders a plain ruby block without 'do'" do
|
67
|
+
src = <<-EOF
|
68
|
+
<ul>
|
69
|
+
# 3.times
|
70
|
+
<li>Hello</li>
|
71
|
+
#end
|
72
|
+
</ul>
|
73
|
+
EOF
|
74
|
+
|
75
|
+
out = <<-EOF
|
76
|
+
<ul>
|
77
|
+
<li>Hello</li>
|
78
|
+
<li>Hello</li>
|
79
|
+
<li>Hello</li>
|
80
|
+
</ul>
|
81
|
+
EOF
|
82
|
+
expect(template src).to eq out
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
it "renders a plain ruby block WITH 'do' and block" do
|
87
|
+
src = <<-EOF
|
88
|
+
<ul>
|
89
|
+
# 3.times do |n|
|
90
|
+
<li>Hello {{ n }}</li>
|
91
|
+
# end
|
92
|
+
</ul>
|
93
|
+
EOF
|
94
|
+
|
95
|
+
out = <<-EOF
|
96
|
+
<ul>
|
97
|
+
<li>Hello 0</li>
|
98
|
+
<li>Hello 1</li>
|
99
|
+
<li>Hello 2</li>
|
100
|
+
</ul>
|
101
|
+
EOF
|
102
|
+
expect(template src).to eq out
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
it "renders if else" do
|
107
|
+
src = <<-EOF
|
108
|
+
first line
|
109
|
+
# if true_condition
|
110
|
+
A main
|
111
|
+
# else
|
112
|
+
A else
|
113
|
+
# end
|
114
|
+
# if false_condition
|
115
|
+
B main
|
116
|
+
# else
|
117
|
+
B else
|
118
|
+
# end
|
119
|
+
EOF
|
120
|
+
|
121
|
+
out = <<-EOF
|
122
|
+
first line
|
123
|
+
A main
|
124
|
+
B else
|
125
|
+
EOF
|
126
|
+
expect(template src).to eq out
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
describe "special controls" do
|
135
|
+
let(:scope) do
|
136
|
+
OpenStruct.new({
|
137
|
+
people: [
|
138
|
+
OpenStruct.new(name: 'Bill'),
|
139
|
+
OpenStruct.new(name: 'Fred')
|
140
|
+
]
|
141
|
+
})
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
it "renders for ... in" do
|
146
|
+
src = <<-EOF
|
147
|
+
# for person in people
|
148
|
+
<p>{{ person.name }}</p>
|
149
|
+
# end
|
150
|
+
EOF
|
151
|
+
|
152
|
+
out = <<-EOF
|
153
|
+
<p>Bill</p>
|
154
|
+
<p>Fred</p>
|
155
|
+
EOF
|
156
|
+
expect(template src).to eq out
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "include" do
|
161
|
+
let(:scope) do
|
162
|
+
OpenStruct.new(
|
163
|
+
message: 'Hello World!',
|
164
|
+
people: [
|
165
|
+
OpenStruct.new(name: 'Bill'),
|
166
|
+
OpenStruct.new(name: 'Fred')
|
167
|
+
]
|
168
|
+
)
|
169
|
+
end
|
170
|
+
|
171
|
+
# an file_provider is anything that responds to "call"
|
172
|
+
# it should return the contents of the file
|
173
|
+
it "renders partials using a file provider" do
|
174
|
+
src = <<-EOF
|
175
|
+
# include my_partial.html
|
176
|
+
<p>content</p>
|
177
|
+
EOF
|
178
|
+
|
179
|
+
file = double("File Provider", call: <<-EOF
|
180
|
+
<p>{{ message }}</p>
|
181
|
+
EOF
|
182
|
+
)
|
183
|
+
|
184
|
+
out = <<-EOF
|
185
|
+
<p>Hello World!</p>
|
186
|
+
<p>content</p>
|
187
|
+
EOF
|
188
|
+
expect( file ).to receive(:call).with('my_partial.html')
|
189
|
+
expect(template(src, {file_provider: file})).to eq out
|
190
|
+
end
|
191
|
+
|
192
|
+
it "renders partials using a default file provider" do
|
193
|
+
File.open('tmp/my_partial.html', 'w') { |f| f.write "<p>{{ message }}</p>" }
|
194
|
+
src = <<-EOF
|
195
|
+
# include tmp/my_partial.html
|
196
|
+
<p>content</p>
|
197
|
+
EOF
|
198
|
+
|
199
|
+
out = <<-EOF
|
200
|
+
<p>Hello World!</p>
|
201
|
+
<p>content</p>
|
202
|
+
EOF
|
203
|
+
expect(template(src)).to eq out
|
204
|
+
File.delete('tmp/my_partial.html')
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
it "provides a meaningful error when template is missing" do
|
209
|
+
src = <<-EOF
|
210
|
+
# include missing.html
|
211
|
+
<p>content</p>
|
212
|
+
EOF
|
213
|
+
|
214
|
+
expect{ template(src) }.to raise_error Rehab::MissingPartialError, "Could not find missing.html"
|
215
|
+
end
|
216
|
+
|
217
|
+
it "works with for .. in comprehension" do
|
218
|
+
src = <<-EOF
|
219
|
+
# include my_partial.html for person in people
|
220
|
+
EOF
|
221
|
+
|
222
|
+
file = ->(ignore) {
|
223
|
+
<<-EOF
|
224
|
+
<p>{{ person.name }}</p>
|
225
|
+
EOF
|
226
|
+
}
|
227
|
+
|
228
|
+
out = <<-EOF
|
229
|
+
<p>Bill</p>
|
230
|
+
<p>Fred</p>
|
231
|
+
EOF
|
232
|
+
expect(template(src, {file_provider: file})).to eq out
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
data/todo.html
ADDED
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rehab
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shane Kuester
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tilt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: temple
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- shout@shanekuester.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- Gemfile.lock
|
121
|
+
- Guardfile
|
122
|
+
- LICENSE
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- lib/rehab.rb
|
126
|
+
- lib/rehab/control.rb
|
127
|
+
- lib/rehab/do_filter.rb
|
128
|
+
- lib/rehab/engine.rb
|
129
|
+
- lib/rehab/file_provider.rb
|
130
|
+
- lib/rehab/filter.rb
|
131
|
+
- lib/rehab/interpolation.rb
|
132
|
+
- lib/rehab/missing_partial_error.rb
|
133
|
+
- lib/rehab/parser.rb
|
134
|
+
- lib/rehab/template.rb
|
135
|
+
- lib/rehab/version.rb
|
136
|
+
- rehab.gemspec
|
137
|
+
- sample.html
|
138
|
+
- spec/.DS_Store
|
139
|
+
- spec/integration_spec.rb
|
140
|
+
- todo.html
|
141
|
+
homepage: https://github.com/skuester/rehab
|
142
|
+
licenses:
|
143
|
+
- MIT
|
144
|
+
metadata: {}
|
145
|
+
post_install_message:
|
146
|
+
rdoc_options: []
|
147
|
+
require_paths:
|
148
|
+
- lib
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
requirements: []
|
160
|
+
rubyforge_project:
|
161
|
+
rubygems_version: 2.0.14
|
162
|
+
signing_key:
|
163
|
+
specification_version: 4
|
164
|
+
summary: Simple, portable template language
|
165
|
+
test_files:
|
166
|
+
- spec/.DS_Store
|
167
|
+
- spec/integration_spec.rb
|