trenni 1.4.1 → 1.4.3
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/.simplecov +9 -0
- data/.travis.yml +1 -0
- data/Gemfile +5 -0
- data/README.md +24 -3
- data/Rakefile +3 -1
- data/lib/trenni/builder.rb +3 -1
- data/lib/trenni/version.rb +1 -1
- data/spec/trenni/builder_spec.rb +17 -1
- data/trenni.gemspec +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b7bbd098228bcbec7f60dd080ae58a1fce57092
|
4
|
+
data.tar.gz: a759d347ef7d1aea336874e6659ecc09a125d665
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fa46a62bfeab0e19d5bc798f1eed8189f81a1d03563251ebed0a17900a7c509c5349d3bfe5d8fd9f9b34fc5958b167aac86612d6e053fdf51e4a52b5befa03e
|
7
|
+
data.tar.gz: 4441c66c6e044736268b1f73e73dd2c7104e6f161d6282a6b566a4211b2fce3201360036c82679511f1b73ef80e38a835a2285d991518a28a5fb039335c39a47
|
data/.simplecov
ADDED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -8,23 +8,27 @@ In addition, Trenni includes an SGML/XML builder to assist with the generation
|
|
8
8
|
of pleasantly formatted markup.
|
9
9
|
|
10
10
|
[](http://travis-ci.org/ioquatix/trenni)
|
11
|
+
[](https://codeclimate.com/github/ioquatix/trenni)
|
12
|
+
[](https://coveralls.io/r/ioquatix/trenni)
|
11
13
|
|
12
14
|
## Installation
|
13
15
|
|
14
16
|
Add this line to your application's Gemfile:
|
15
17
|
|
16
|
-
|
18
|
+
gem 'trenni'
|
17
19
|
|
18
20
|
And then execute:
|
19
21
|
|
20
|
-
|
22
|
+
$ bundle
|
21
23
|
|
22
24
|
Or install it yourself as:
|
23
25
|
|
24
|
-
|
26
|
+
$ gem install trenni
|
25
27
|
|
26
28
|
## Usage
|
27
29
|
|
30
|
+
### Templates
|
31
|
+
|
28
32
|
Trenni templates work essentially the same way as all other templating systems:
|
29
33
|
|
30
34
|
template = Trenni::Template.new('<?r items.each do |item| ?>#{item}<?r end ?>')
|
@@ -37,6 +41,23 @@ The code above demonstrate the only two constructs, `<?r expression ?>` and `#{
|
|
37
41
|
|
38
42
|
Trenni provides a slightly higher performance API using objects rather than bindings. If you provide an object instance, `instance_eval` would be used instead.
|
39
43
|
|
44
|
+
### Builder
|
45
|
+
|
46
|
+
Trenni can help construct XML/HTML using a simple DSL:
|
47
|
+
|
48
|
+
Trenni::Builder.fragment do |builder|
|
49
|
+
builder.inline 'p' do
|
50
|
+
builder.tag 'strong' do
|
51
|
+
builder.text 'Hello'
|
52
|
+
end
|
53
|
+
builder.text ' World'
|
54
|
+
end
|
55
|
+
builder.tag 'script', type: 'text/html' do
|
56
|
+
builder.text 'console.log("Hello World")'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
# => "<p><strong>Hello</strong> World</p>\n<script type=\"text/html\">\n\tconsole.log(\"Hello World\")\n</script>"
|
60
|
+
|
40
61
|
## Contributing
|
41
62
|
|
42
63
|
1. Fork it
|
data/Rakefile
CHANGED
data/lib/trenni/builder.rb
CHANGED
@@ -21,7 +21,6 @@
|
|
21
21
|
require 'trenni/strings'
|
22
22
|
|
23
23
|
module Trenni
|
24
|
-
|
25
24
|
INSTRUCT_ATTRIBUTES = [
|
26
25
|
['version', '1.0'],
|
27
26
|
['encoding', 'UTF-8']
|
@@ -180,6 +179,9 @@ module Trenni
|
|
180
179
|
|
181
180
|
@output.write "</#{name}>"
|
182
181
|
else
|
182
|
+
# The parent has one more child:
|
183
|
+
@level[-1] += 1
|
184
|
+
|
183
185
|
@output.write indentation + "<#{name}#{tag_attributes(attributes)}/>"
|
184
186
|
end
|
185
187
|
end
|
data/lib/trenni/version.rb
CHANGED
data/spec/trenni/builder_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env
|
1
|
+
#!/usr/bin/env rspec
|
2
2
|
|
3
3
|
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
4
|
#
|
@@ -52,6 +52,14 @@ module Trenni::BuilderSpec
|
|
52
52
|
expect(builder.output.string).to be == "<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<title>Hello World</title>\n\t</head>\n\t<body>\n\t</body>\n</html>"
|
53
53
|
end
|
54
54
|
|
55
|
+
it "should indent self-closing tag correctly" do
|
56
|
+
builder = Trenni::Builder.new
|
57
|
+
|
58
|
+
builder.tag('foo') { builder.tag('bar') }
|
59
|
+
|
60
|
+
expect(builder.output.string).to be == "<foo>\n\t<bar/>\n</foo>"
|
61
|
+
end
|
62
|
+
|
55
63
|
it "should produce inline html" do
|
56
64
|
builder = Trenni::Builder.new(:indent => true)
|
57
65
|
|
@@ -92,6 +100,14 @@ module Trenni::BuilderSpec
|
|
92
100
|
expect(builder.output.string).to be == %Q{<option required/>}
|
93
101
|
end
|
94
102
|
|
103
|
+
it "should output without changing escaped characters" do
|
104
|
+
builder = Trenni::Builder.new(:strict => false)
|
105
|
+
|
106
|
+
builder.tag "section", :'data-text' => 'foo\nbar'
|
107
|
+
|
108
|
+
expect(builder.output.string).to be == '<section data-text="foo\nbar"/>'
|
109
|
+
end
|
110
|
+
|
95
111
|
it "should order attributes as specified" do
|
96
112
|
builder = Trenni::Builder.new(:strict => true)
|
97
113
|
builder.tag :t, [[:a, 10], [:b, 20]]
|
data/trenni.gemspec
CHANGED
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.3"
|
28
|
-
spec.add_development_dependency "rspec", "~> 3.
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.4.0"
|
29
29
|
spec.add_development_dependency "rake"
|
30
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trenni
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.
|
33
|
+
version: 3.4.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.
|
40
|
+
version: 3.4.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -63,6 +63,7 @@ extensions: []
|
|
63
63
|
extra_rdoc_files: []
|
64
64
|
files:
|
65
65
|
- ".gitignore"
|
66
|
+
- ".simplecov"
|
66
67
|
- ".travis.yml"
|
67
68
|
- Gemfile
|
68
69
|
- README.md
|
@@ -99,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
100
|
version: '0'
|
100
101
|
requirements: []
|
101
102
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.4.6
|
103
104
|
signing_key:
|
104
105
|
specification_version: 4
|
105
106
|
summary: A fast native templating system that compiles directly to Ruby code.
|