armadillo 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/armadillo.gemspec +1 -1
- data/lib/armadillo.rb +22 -3
- data/spec/template_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 803ab702bb0ecc685d7197c02f3d25589e2cd0fd
|
4
|
+
data.tar.gz: e2de66ea90d89b6fa52d6304c4936027ea89f151
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b698b6d91589250f691ae6f0e956da0307633e7b3aac6a333d4a9bbf2a02091ad7894cd04d0c0df64a7c50f994d4e44c93477eb470c8cb75412a17fd4d228019
|
7
|
+
data.tar.gz: 52d57126647cb0dda2332de5ef9e5b8fc8812af2ec9f45af72bfdc7b5a75cea7bc1facff0492194efec5420d0b5b09dcafe7d3fa76031283e0099b2f3bc033ed
|
data/README.md
CHANGED
@@ -58,7 +58,8 @@ module View
|
|
58
58
|
def render_view(template_name, locals = {})
|
59
59
|
content = Armadillo.render(template_name, locals, {
|
60
60
|
:base_path => File.join(APP_PATH, "views"),
|
61
|
-
:scope => self
|
61
|
+
:scope => self,
|
62
|
+
:escape_html => true
|
62
63
|
})
|
63
64
|
res.write(content)
|
64
65
|
halt(res.finish)
|
data/armadillo.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "armadillo"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.2"
|
4
4
|
s.summary = "Template inheritance with ERB templates"
|
5
5
|
s.description = "A small library for Django-like template inheritance adapted for ERB"
|
6
6
|
s.authors = ["Sebastian Borrazas"]
|
data/lib/armadillo.rb
CHANGED
@@ -3,7 +3,7 @@ require "delegate"
|
|
3
3
|
|
4
4
|
module Armadillo
|
5
5
|
|
6
|
-
VERSION = "0.0.
|
6
|
+
VERSION = "0.0.2"
|
7
7
|
|
8
8
|
DEFAULT_OPTIONS = {
|
9
9
|
:default_encoding => Encoding.default_external,
|
@@ -13,6 +13,15 @@ module Armadillo
|
|
13
13
|
# @api private
|
14
14
|
class TemplateContext < SimpleDelegator
|
15
15
|
|
16
|
+
# Initialize the TemplateContext.
|
17
|
+
#
|
18
|
+
# @param source [Object]
|
19
|
+
# @param template_options [Hash] ({})
|
20
|
+
def initialize(source, template_options = {})
|
21
|
+
@template_options = template_options
|
22
|
+
super(source)
|
23
|
+
end
|
24
|
+
|
16
25
|
# Extend the specified template in which the inner view blocks will be
|
17
26
|
# rendered.
|
18
27
|
#
|
@@ -57,6 +66,16 @@ module Armadillo
|
|
57
66
|
}
|
58
67
|
end
|
59
68
|
|
69
|
+
# Render another template with the same options as the current one.
|
70
|
+
#
|
71
|
+
# @param template_path [String]
|
72
|
+
# @param locals [Hash] ({})
|
73
|
+
#
|
74
|
+
# @return [String]
|
75
|
+
def render(template_path, locals = {})
|
76
|
+
Armadillo.render(template_path, locals, @template_options)
|
77
|
+
end
|
78
|
+
|
60
79
|
# Determine if the current template should extend from a new template.
|
61
80
|
#
|
62
81
|
# @return [Boolean]
|
@@ -121,8 +140,8 @@ module Armadillo
|
|
121
140
|
# @return [String]
|
122
141
|
# @api public
|
123
142
|
def self.render(template_path, locals = {}, options = {})
|
124
|
-
scope = options.
|
125
|
-
context = TemplateContext.new(scope)
|
143
|
+
scope = options.delete(:scope) { Object.new }
|
144
|
+
context = TemplateContext.new(scope, options)
|
126
145
|
_render(template_path, locals, context, options)
|
127
146
|
end
|
128
147
|
|
data/spec/template_spec.rb
CHANGED
@@ -76,6 +76,19 @@ describe Armadillo do
|
|
76
76
|
assert_lines_match(content, ["Sanitized &", "Not sanitized &"])
|
77
77
|
end
|
78
78
|
end
|
79
|
+
|
80
|
+
describe "when the template renders another template" do
|
81
|
+
it "renders it with the same options" do
|
82
|
+
content = Armadillo.render("with_sub_template.html", {}, {
|
83
|
+
:base_path => TEMPLATES_PATH,
|
84
|
+
:escape_html => true
|
85
|
+
})
|
86
|
+
assert_lines_match(content, [
|
87
|
+
"<h1>Title</h1>",
|
88
|
+
"<h2>Subtitle</h2>"
|
89
|
+
])
|
90
|
+
end
|
91
|
+
end
|
79
92
|
end
|
80
93
|
|
81
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: armadillo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Borrazas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tilt
|