tilt-twig 0.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 +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +40 -0
- data/Rakefile +2 -0
- data/lib/middleman/renderers/twig.rb +30 -0
- data/lib/middleman/twig.rb +43 -0
- data/lib/middleman_extension.rb +1 -0
- data/lib/tilt/twig/version.rb +5 -0
- data/lib/tilt/twig.rb +51 -0
- data/php/composer.json +5 -0
- data/php/composer.lock +272 -0
- data/php/example/test.twig +1 -0
- data/php/example/test.yml +1 -0
- data/php/example.sh +1 -0
- data/php/install.php +10 -0
- data/php/php.ini +1 -0
- data/php/render.php +19 -0
- data/tilt-twig.gemspec +23 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 65c273e928797341e8dca083f2116252a277ab28
|
4
|
+
data.tar.gz: 4a67dfc9cd29cf44659c9bb9d41dc6713b833669
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 263db1725d3aab93f9743ca358d5056da270fcf33f7b44ea2b242722af0d536691e84861aa5f3b2de8bb140ed14bc192742dc09cd96aa2897058991b897572e5
|
7
|
+
data.tar.gz: d140db3726e9ff91e474c42e13c29ba35e2f240d5656f22344764307425c7cd17ec821699952d0f0a91f88c7279ac664e574ce4f2354a6d3c6000931611c4f70
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
php/vendor
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Joel Van Horn
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
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:
|
12
|
+
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Tilt::Twig
|
2
|
+
|
3
|
+
**WARNING: EXPERIMENTAL**
|
4
|
+
|
5
|
+
This gem allows you to compile Twig templates within Ruby applications that support Tilt templates. This is currently not a native Ruby parser, but rather utilizes PHP command line to compile Twig templates. Data is serialized to YAML in your Ruby application and deserialized in a PHP script that passes the context to Twig.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
This gem has PHP dependencies, which are attempted to be [installed automatically](php/install.php):
|
10
|
+
|
11
|
+
* PECL
|
12
|
+
* `libyaml` (via [Homebrew](http://brew.sh))
|
13
|
+
* PHP's `yaml`
|
14
|
+
* [Composer](https://getcomposer.org)
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
gem 'tilt-twig'
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install tilt-twig
|
27
|
+
|
28
|
+
### Middleman
|
29
|
+
|
30
|
+
A [Middleman](http://middlemanapp.com) extension is built-in.
|
31
|
+
|
32
|
+
gem 'tilt-twig', require: 'middleman/twig'
|
33
|
+
|
34
|
+
Add the extension to the Middleman configuration:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
configure :build do
|
38
|
+
activate :twig_extension
|
39
|
+
end
|
40
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'tilt/twig'
|
2
|
+
require 'middleman-core/templates'
|
3
|
+
|
4
|
+
# Twig Renderer
|
5
|
+
module Middleman
|
6
|
+
module Renderers
|
7
|
+
module Twig
|
8
|
+
class << self
|
9
|
+
def registered(app)
|
10
|
+
app.before_configuration do
|
11
|
+
template_extensions twig: :html
|
12
|
+
end
|
13
|
+
# Twig is not included in the default gems,
|
14
|
+
# but we'll support it if available.
|
15
|
+
|
16
|
+
# After config, setup mustache partial paths
|
17
|
+
app.after_configuration do
|
18
|
+
# Convert data object into a hash for twig
|
19
|
+
sitemap.provides_metadata %r{\.twig$} do
|
20
|
+
{ :locals => { :data => data.to_h } }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
alias :included :registered
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
#Middleman::Templates.register :twig, Middleman::Renderers::Twig
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Require core library
|
2
|
+
require 'middleman-core'
|
3
|
+
require 'middleman/renderers/twig'
|
4
|
+
|
5
|
+
# Extension namespace
|
6
|
+
module Middleman
|
7
|
+
class TwigExtension < ::Middleman::Extension
|
8
|
+
#option :my_option, 'default', 'An example option'
|
9
|
+
|
10
|
+
def initialize(app, options_hash={}, &block)
|
11
|
+
# Call super to build options from the options_hash
|
12
|
+
super
|
13
|
+
|
14
|
+
# Require libraries only when activated
|
15
|
+
# require 'necessary/library'
|
16
|
+
|
17
|
+
# set up your extension
|
18
|
+
# puts options.my_option
|
19
|
+
|
20
|
+
app.register Middleman::Renderers::Twig
|
21
|
+
end
|
22
|
+
|
23
|
+
def after_configuration
|
24
|
+
# Do something
|
25
|
+
end
|
26
|
+
|
27
|
+
# A Sitemap Manipulator
|
28
|
+
# def manipulate_resource_list(resources)
|
29
|
+
# end
|
30
|
+
|
31
|
+
# module do
|
32
|
+
# def a_helper
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Register extensions which can be activated
|
39
|
+
# Make sure we have the version of Middleman we expect
|
40
|
+
# Name param may be omited, it will default to underscored
|
41
|
+
# version of class name
|
42
|
+
|
43
|
+
Middleman::Extensions.register(:twig_extension, Middleman::TwigExtension)
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'middleman/twig'
|
data/lib/tilt/twig.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Tilt
|
5
|
+
class TwigTemplate < Template
|
6
|
+
def initialize_engine
|
7
|
+
install_php_dependencies
|
8
|
+
end
|
9
|
+
|
10
|
+
def prepare; end
|
11
|
+
|
12
|
+
def evaluate(scope, locals, &block)
|
13
|
+
|
14
|
+
template_file = Tempfile.new(['template-', '.twig'])
|
15
|
+
yaml_file = Tempfile.new(['context-', '.yml'])
|
16
|
+
yaml_data = locals.merge(scope.is_a?(Hash) ? scope : {}).stringify_keys
|
17
|
+
|
18
|
+
begin
|
19
|
+
File.open(template_file.path, 'w'){|file| file.write(data)}
|
20
|
+
File.open(yaml_file.path, 'w'){|file| file.write(yaml_data.to_yaml)}
|
21
|
+
|
22
|
+
php_ini_path = "#{gem_root_path}/php/php.ini"
|
23
|
+
renderer_path = "#{gem_root_path}/php/render.php"
|
24
|
+
templates_path = File.dirname(template_file.path)
|
25
|
+
template_name = File.basename(template_file.path)
|
26
|
+
yaml_dump_path = yaml_file.path
|
27
|
+
|
28
|
+
result = `php --php-ini "#{php_ini_path}" "#{renderer_path}" "#{templates_path}" "#{template_name}" "#{yaml_dump_path}"`
|
29
|
+
rescue
|
30
|
+
raise
|
31
|
+
ensure
|
32
|
+
template_file.close
|
33
|
+
template_file.unlink
|
34
|
+
yaml_file.close
|
35
|
+
yaml_file.unlink
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def install_php_dependencies
|
41
|
+
Dir.chdir(gem_root_path){`php php/install.php`}
|
42
|
+
end
|
43
|
+
|
44
|
+
def gem_root_path
|
45
|
+
File.expand_path '../../..', __FILE__
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
register 'twig', TwigTemplate
|
50
|
+
end
|
51
|
+
|
data/php/composer.json
ADDED
data/php/composer.lock
ADDED
@@ -0,0 +1,272 @@
|
|
1
|
+
{
|
2
|
+
"_readme": [
|
3
|
+
"This file locks the dependencies of your project to a known state",
|
4
|
+
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
5
|
+
"This file is @generated automatically"
|
6
|
+
],
|
7
|
+
"hash": "bee285cd607744b74e4892bcb9fc7171",
|
8
|
+
"packages": [
|
9
|
+
{
|
10
|
+
"name": "altorouter/altorouter",
|
11
|
+
"version": "v1.1.0",
|
12
|
+
"source": {
|
13
|
+
"type": "git",
|
14
|
+
"url": "https://github.com/dannyvankooten/AltoRouter.git",
|
15
|
+
"reference": "09d9d946c546bae6d22a7654cdb3b825ffda54b4"
|
16
|
+
},
|
17
|
+
"dist": {
|
18
|
+
"type": "zip",
|
19
|
+
"url": "https://api.github.com/repos/dannyvankooten/AltoRouter/zipball/09d9d946c546bae6d22a7654cdb3b825ffda54b4",
|
20
|
+
"reference": "09d9d946c546bae6d22a7654cdb3b825ffda54b4",
|
21
|
+
"shasum": ""
|
22
|
+
},
|
23
|
+
"require": {
|
24
|
+
"php": ">=5.3.0"
|
25
|
+
},
|
26
|
+
"type": "library",
|
27
|
+
"autoload": {
|
28
|
+
"classmap": [
|
29
|
+
"AltoRouter.php"
|
30
|
+
]
|
31
|
+
},
|
32
|
+
"notification-url": "https://packagist.org/downloads/",
|
33
|
+
"license": [
|
34
|
+
"MIT"
|
35
|
+
],
|
36
|
+
"authors": [
|
37
|
+
{
|
38
|
+
"name": "Danny van Kooten",
|
39
|
+
"email": "dannyvankooten@gmail.com",
|
40
|
+
"homepage": "http://dannyvankooten.com/"
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"name": "Koen Punt",
|
44
|
+
"homepage": "https://github.com/koenpunt"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"name": "niahoo",
|
48
|
+
"homepage": "https://github.com/niahoo"
|
49
|
+
}
|
50
|
+
],
|
51
|
+
"description": "A lightning fast router for PHP",
|
52
|
+
"homepage": "https://github.com/dannyvankooten/AltoRouter",
|
53
|
+
"keywords": [
|
54
|
+
"lightweight",
|
55
|
+
"router",
|
56
|
+
"routing"
|
57
|
+
],
|
58
|
+
"time": "2014-04-16 09:44:40"
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"name": "asm89/twig-cache-extension",
|
62
|
+
"version": "1.0.0",
|
63
|
+
"source": {
|
64
|
+
"type": "git",
|
65
|
+
"url": "https://github.com/asm89/twig-cache-extension.git",
|
66
|
+
"reference": "92edc2ab522997fd0a2a02b6b9e89b3e08ac5c60"
|
67
|
+
},
|
68
|
+
"dist": {
|
69
|
+
"type": "zip",
|
70
|
+
"url": "https://api.github.com/repos/asm89/twig-cache-extension/zipball/92edc2ab522997fd0a2a02b6b9e89b3e08ac5c60",
|
71
|
+
"reference": "92edc2ab522997fd0a2a02b6b9e89b3e08ac5c60",
|
72
|
+
"shasum": ""
|
73
|
+
},
|
74
|
+
"require": {
|
75
|
+
"php": ">=5.3.2",
|
76
|
+
"twig/twig": "1.*"
|
77
|
+
},
|
78
|
+
"require-dev": {
|
79
|
+
"doctrine/cache": "1.*"
|
80
|
+
},
|
81
|
+
"type": "library",
|
82
|
+
"extra": {
|
83
|
+
"branch-alias": {
|
84
|
+
"dev-master": "1.0-dev"
|
85
|
+
}
|
86
|
+
},
|
87
|
+
"autoload": {
|
88
|
+
"psr-0": {
|
89
|
+
"Asm89\\Twig\\CacheExtension\\": "lib/"
|
90
|
+
}
|
91
|
+
},
|
92
|
+
"notification-url": "https://packagist.org/downloads/",
|
93
|
+
"license": [
|
94
|
+
"MIT"
|
95
|
+
],
|
96
|
+
"authors": [
|
97
|
+
{
|
98
|
+
"name": "Alexander",
|
99
|
+
"email": "iam.asm89@gmail.com",
|
100
|
+
"homepage": "http://asm89.github.io/"
|
101
|
+
}
|
102
|
+
],
|
103
|
+
"description": "Caching template fragments with Twig.",
|
104
|
+
"homepage": "https://github.com/asm89/twig-cache-extension",
|
105
|
+
"keywords": [
|
106
|
+
"cache",
|
107
|
+
"extension",
|
108
|
+
"twig"
|
109
|
+
],
|
110
|
+
"time": "2014-05-31 13:57:16"
|
111
|
+
},
|
112
|
+
{
|
113
|
+
"name": "composer/installers",
|
114
|
+
"version": "v1.0.21",
|
115
|
+
"source": {
|
116
|
+
"type": "git",
|
117
|
+
"url": "https://github.com/composer/installers.git",
|
118
|
+
"reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45"
|
119
|
+
},
|
120
|
+
"dist": {
|
121
|
+
"type": "zip",
|
122
|
+
"url": "https://api.github.com/repos/composer/installers/zipball/d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
|
123
|
+
"reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
|
124
|
+
"shasum": ""
|
125
|
+
},
|
126
|
+
"replace": {
|
127
|
+
"roundcube/plugin-installer": "*",
|
128
|
+
"shama/baton": "*"
|
129
|
+
},
|
130
|
+
"require-dev": {
|
131
|
+
"composer/composer": "1.0.*@dev",
|
132
|
+
"phpunit/phpunit": "4.1.*"
|
133
|
+
},
|
134
|
+
"type": "composer-installer",
|
135
|
+
"extra": {
|
136
|
+
"class": "Composer\\Installers\\Installer",
|
137
|
+
"branch-alias": {
|
138
|
+
"dev-master": "1.0-dev"
|
139
|
+
}
|
140
|
+
},
|
141
|
+
"autoload": {
|
142
|
+
"psr-0": {
|
143
|
+
"Composer\\Installers\\": "src/"
|
144
|
+
}
|
145
|
+
},
|
146
|
+
"notification-url": "https://packagist.org/downloads/",
|
147
|
+
"license": [
|
148
|
+
"MIT"
|
149
|
+
],
|
150
|
+
"authors": [
|
151
|
+
{
|
152
|
+
"name": "Kyle Robinson Young",
|
153
|
+
"email": "kyle@dontkry.com",
|
154
|
+
"homepage": "https://github.com/shama"
|
155
|
+
}
|
156
|
+
],
|
157
|
+
"description": "A multi-framework Composer library installer",
|
158
|
+
"homepage": "http://composer.github.com/installers/",
|
159
|
+
"keywords": [
|
160
|
+
"Craft",
|
161
|
+
"Dolibarr",
|
162
|
+
"Hurad",
|
163
|
+
"MODX Evo",
|
164
|
+
"OXID",
|
165
|
+
"SMF",
|
166
|
+
"Thelia",
|
167
|
+
"WolfCMS",
|
168
|
+
"agl",
|
169
|
+
"aimeos",
|
170
|
+
"annotatecms",
|
171
|
+
"bitrix",
|
172
|
+
"cakephp",
|
173
|
+
"chef",
|
174
|
+
"codeigniter",
|
175
|
+
"concrete5",
|
176
|
+
"croogo",
|
177
|
+
"dokuwiki",
|
178
|
+
"drupal",
|
179
|
+
"elgg",
|
180
|
+
"fuelphp",
|
181
|
+
"grav",
|
182
|
+
"installer",
|
183
|
+
"joomla",
|
184
|
+
"kohana",
|
185
|
+
"laravel",
|
186
|
+
"lithium",
|
187
|
+
"magento",
|
188
|
+
"mako",
|
189
|
+
"mediawiki",
|
190
|
+
"modulework",
|
191
|
+
"moodle",
|
192
|
+
"phpbb",
|
193
|
+
"piwik",
|
194
|
+
"ppi",
|
195
|
+
"puppet",
|
196
|
+
"roundcube",
|
197
|
+
"shopware",
|
198
|
+
"silverstripe",
|
199
|
+
"symfony",
|
200
|
+
"typo3",
|
201
|
+
"wordpress",
|
202
|
+
"zend",
|
203
|
+
"zikula"
|
204
|
+
],
|
205
|
+
"time": "2015-02-18 17:17:01"
|
206
|
+
},
|
207
|
+
{
|
208
|
+
"name": "twig/twig",
|
209
|
+
"version": "v1.18.0",
|
210
|
+
"source": {
|
211
|
+
"type": "git",
|
212
|
+
"url": "https://github.com/twigphp/Twig.git",
|
213
|
+
"reference": "4cf7464348e7f9893a93f7096a90b73722be99cf"
|
214
|
+
},
|
215
|
+
"dist": {
|
216
|
+
"type": "zip",
|
217
|
+
"url": "https://api.github.com/repos/twigphp/Twig/zipball/4cf7464348e7f9893a93f7096a90b73722be99cf",
|
218
|
+
"reference": "4cf7464348e7f9893a93f7096a90b73722be99cf",
|
219
|
+
"shasum": ""
|
220
|
+
},
|
221
|
+
"require": {
|
222
|
+
"php": ">=5.2.4"
|
223
|
+
},
|
224
|
+
"type": "library",
|
225
|
+
"extra": {
|
226
|
+
"branch-alias": {
|
227
|
+
"dev-master": "1.18-dev"
|
228
|
+
}
|
229
|
+
},
|
230
|
+
"autoload": {
|
231
|
+
"psr-0": {
|
232
|
+
"Twig_": "lib/"
|
233
|
+
}
|
234
|
+
},
|
235
|
+
"notification-url": "https://packagist.org/downloads/",
|
236
|
+
"license": [
|
237
|
+
"BSD-3-Clause"
|
238
|
+
],
|
239
|
+
"authors": [
|
240
|
+
{
|
241
|
+
"name": "Fabien Potencier",
|
242
|
+
"email": "fabien@symfony.com",
|
243
|
+
"homepage": "http://fabien.potencier.org",
|
244
|
+
"role": "Lead Developer"
|
245
|
+
},
|
246
|
+
{
|
247
|
+
"name": "Armin Ronacher",
|
248
|
+
"email": "armin.ronacher@active-4.com",
|
249
|
+
"role": "Project Founder"
|
250
|
+
},
|
251
|
+
{
|
252
|
+
"name": "Twig Team",
|
253
|
+
"homepage": "http://twig.sensiolabs.org/contributors",
|
254
|
+
"role": "Contributors"
|
255
|
+
}
|
256
|
+
],
|
257
|
+
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
258
|
+
"homepage": "http://twig.sensiolabs.org",
|
259
|
+
"keywords": [
|
260
|
+
"templating"
|
261
|
+
],
|
262
|
+
"time": "2015-01-25 17:32:08"
|
263
|
+
}
|
264
|
+
],
|
265
|
+
"packages-dev": [],
|
266
|
+
"aliases": [],
|
267
|
+
"minimum-stability": "stable",
|
268
|
+
"stability-flags": [],
|
269
|
+
"prefer-stable": false,
|
270
|
+
"platform": [],
|
271
|
+
"platform-dev": []
|
272
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello {{ name }}!
|
@@ -0,0 +1 @@
|
|
1
|
+
name: JOEL
|
data/php/example.sh
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
php --php-ini ./php.ini render.php "./example" "test.twig" "./example/test.yml"
|
data/php/install.php
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
<?php
|
2
|
+
// REQUIRES: Composer, libyaml, PEAR/PECL
|
3
|
+
// Install Composer
|
4
|
+
exec('composer install') . "\n";
|
5
|
+
|
6
|
+
// Install YAML dependencies
|
7
|
+
// TODO: Check to see if this is needed first.....
|
8
|
+
exec('brew install libyaml --universal');
|
9
|
+
// Install YAML and simulate "enter" for auto-dependency prompt
|
10
|
+
exec('printf "\n" | pecl install yaml');
|
data/php/php.ini
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
//extension=yaml.so
|
data/php/render.php
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
<?php
|
2
|
+
// REQUIRES: Composer, libyaml, PEAR/PECL
|
3
|
+
|
4
|
+
// Reference Composer auto-loader
|
5
|
+
include_once realpath(dirname(__FILE__)) . '/vendor/autoload.php';
|
6
|
+
|
7
|
+
$templates_dir_path = $argv[1];
|
8
|
+
$template_file_path = $argv[2];
|
9
|
+
$context_yaml_file_path = $argv[3];
|
10
|
+
|
11
|
+
$context_data = yaml_parse_file($context_yaml_file_path);
|
12
|
+
|
13
|
+
Twig_Autoloader::register();
|
14
|
+
|
15
|
+
$loader = new Twig_Loader_Filesystem($templates_dir_path);
|
16
|
+
$twig = new Twig_Environment($loader);
|
17
|
+
|
18
|
+
echo $twig->render($template_file_path, $context_data);
|
19
|
+
echo "\n";
|
data/tilt-twig.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tilt/twig/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tilt-twig"
|
8
|
+
spec.version = Tilt::Twig::VERSION
|
9
|
+
spec.authors = ["Joel Van Horn"]
|
10
|
+
spec.email = ["joel@joelvanhorn.com"]
|
11
|
+
spec.summary = %q{Compile Twig templates with Tilt and PHP}
|
12
|
+
spec.description = %q{This gem allows you to compile Twig templates within Ruby applications that support Tilt templates. This is currently not a native Ruby parser, but rather utilizes PHP command line to compile Twig templates. Data is serialized to YAML in your Ruby application and deserialized in a PHP script that passes the context to Twig.}
|
13
|
+
spec.homepage = "http://github.com/joelvh/tilt-twig"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tilt-twig
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joel Van Horn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: This gem allows you to compile Twig templates within Ruby applications
|
42
|
+
that support Tilt templates. This is currently not a native Ruby parser, but rather
|
43
|
+
utilizes PHP command line to compile Twig templates. Data is serialized to YAML
|
44
|
+
in your Ruby application and deserialized in a PHP script that passes the context
|
45
|
+
to Twig.
|
46
|
+
email:
|
47
|
+
- joel@joelvanhorn.com
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- ".gitignore"
|
53
|
+
- Gemfile
|
54
|
+
- LICENSE.txt
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- lib/middleman/renderers/twig.rb
|
58
|
+
- lib/middleman/twig.rb
|
59
|
+
- lib/middleman_extension.rb
|
60
|
+
- lib/tilt/twig.rb
|
61
|
+
- lib/tilt/twig/version.rb
|
62
|
+
- php/composer.json
|
63
|
+
- php/composer.lock
|
64
|
+
- php/example.sh
|
65
|
+
- php/example/test.twig
|
66
|
+
- php/example/test.yml
|
67
|
+
- php/install.php
|
68
|
+
- php/php.ini
|
69
|
+
- php/render.php
|
70
|
+
- tilt-twig.gemspec
|
71
|
+
homepage: http://github.com/joelvh/tilt-twig
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.4.5
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Compile Twig templates with Tilt and PHP
|
95
|
+
test_files: []
|