tilt-rails_erb 1.0.0
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/CHANGELOG +3 -0
- data/MIT-LICENSE +18 -0
- data/README.rdoc +35 -0
- data/Rakefile +45 -0
- data/lib/tilt/rails_erb.rb +27 -0
- data/spec/template.erb +1 -0
- data/spec/tilt_rails_erb_spec.rb +26 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 73d8b4e0818d48ae98b297225775540bd5d19806
|
4
|
+
data.tar.gz: c6874f256073b35cefb78ba9d96122bfce1e9454
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8f98642e6daae57c58d2c9c5c11133e7d13e1430a79be7c134cd890f5a943b45c135e7a5bac75bcd9ed885cc8913bc12d4c235929e014d2949914f8ebc95817f
|
7
|
+
data.tar.gz: 2753f5a91bd45fce632cee0eeaf0ac7b2c4173a7c15a77a27fabb16fbaa5215a674293211cce5e29d282d045bb2bfd98606d0c29d38205e6d2cc958e22a2554d
|
data/CHANGELOG
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright (c) 2016 Jeremy Evans
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to
|
5
|
+
deal in the Software without restriction, including without limitation the
|
6
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
16
|
+
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
= tilt-rails_erb
|
2
|
+
|
3
|
+
tilt-rails_erb adds supports ERB templates using Rails' ERB handler,
|
4
|
+
which is different than standard ERB in that it supports using
|
5
|
+
<tt><%= foo do %><% end %></tt> syntax and it auto-escapes output.
|
6
|
+
|
7
|
+
= Installation
|
8
|
+
|
9
|
+
gem install tilt-rails_erb
|
10
|
+
|
11
|
+
= Source Code
|
12
|
+
|
13
|
+
Source code is available on GitHub at https://github.com/jeremyevans/tilt-rails_erb
|
14
|
+
|
15
|
+
= Usage
|
16
|
+
|
17
|
+
require 'tilt/rails_erb'
|
18
|
+
|
19
|
+
The use case for tilt-rails_erb is in middleware in a Rails app that wants to share
|
20
|
+
template files with the Rails app. Rails uses a non-standard ERB processor, and
|
21
|
+
supports syntax that standard ERB doesn't support. If you use that syntax in your
|
22
|
+
Rails templates and want to share the templates with a middleware that uses tilt
|
23
|
+
for renderning, you should use this library.
|
24
|
+
|
25
|
+
Note that this library makes the the Tilt::RailsERBTemplate the default Tilt
|
26
|
+
.erb template handler, which can cause problems if you also use non-Rails ERB
|
27
|
+
templates in the same application.
|
28
|
+
|
29
|
+
= License
|
30
|
+
|
31
|
+
MIT
|
32
|
+
|
33
|
+
= Author
|
34
|
+
|
35
|
+
Jeremy Evans <code@jeremyevans.net>
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require "rake"
|
2
|
+
require "rake/clean"
|
3
|
+
|
4
|
+
CLEAN.include ["tilt-rails_erb-*.gem", "rdoc", "coverage"]
|
5
|
+
|
6
|
+
desc "Build tilt-rails_erb gem"
|
7
|
+
task :package=>[:clean] do |p|
|
8
|
+
sh %{#{FileUtils::RUBY} -S gem build tilt-rails_erb.gemspec}
|
9
|
+
end
|
10
|
+
|
11
|
+
### Specs
|
12
|
+
|
13
|
+
desc "Run tests"
|
14
|
+
task :test do
|
15
|
+
sh "#{FileUtils::RUBY} -rubygems spec/tilt_rails_erb_spec.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => :test
|
19
|
+
|
20
|
+
### RDoc
|
21
|
+
|
22
|
+
RDOC_DEFAULT_OPTS = ["--quiet", "--line-numbers", "--inline-source", '--title', 'tilt-rails_erb: Tilt support for Rails ERB templates']
|
23
|
+
|
24
|
+
begin
|
25
|
+
gem 'hanna-nouveau'
|
26
|
+
RDOC_DEFAULT_OPTS.concat(['-f', 'hanna'])
|
27
|
+
rescue Gem::LoadError
|
28
|
+
end
|
29
|
+
|
30
|
+
rdoc_task_class = begin
|
31
|
+
require "rdoc/task"
|
32
|
+
RDoc::Task
|
33
|
+
rescue LoadError
|
34
|
+
require "rake/rdoctask"
|
35
|
+
Rake::RDocTask
|
36
|
+
end
|
37
|
+
|
38
|
+
RDOC_OPTS = RDOC_DEFAULT_OPTS + ['--main', 'README.rdoc']
|
39
|
+
|
40
|
+
rdoc_task_class.new do |rdoc|
|
41
|
+
rdoc.rdoc_dir = "rdoc"
|
42
|
+
rdoc.options += RDOC_OPTS
|
43
|
+
rdoc.rdoc_files.add %w"README.rdoc CHANGELOG MIT-LICENSE lib/**/*.rb"
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
require 'tilt/template'
|
3
|
+
require 'action_view'
|
4
|
+
|
5
|
+
module Tilt
|
6
|
+
class RailsERBTemplate < ErubisTemplate
|
7
|
+
protected
|
8
|
+
|
9
|
+
class Template < ActionView::Template::Handlers::Erubis
|
10
|
+
def add_preamble(_)
|
11
|
+
@newline_pending = 0
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def prepare
|
16
|
+
@outvar = options.delete(:outvar) || '@output_buffer'
|
17
|
+
@options.merge!(:postamble => false, :bufvar => @outvar)
|
18
|
+
@engine = Template.new(data, options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def precompiled_preamble(locals)
|
22
|
+
[super, "#{@outvar} = output_buffer = _buf = ActionView::OutputBuffer.new"].join("\n")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
register(RailsERBTemplate, 'erb')
|
27
|
+
end
|
data/spec/template.erb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
t1<%= a do %><%= '<t2>' %><%= '<t3>'.html_safe %><% end %>t4
|
@@ -0,0 +1,26 @@
|
|
1
|
+
$: << 'lib'
|
2
|
+
require 'minitest/spec'
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'tilt'
|
5
|
+
require 'tilt/rails_erb'
|
6
|
+
|
7
|
+
describe "tilt-rails_erb" do
|
8
|
+
def a
|
9
|
+
buf = @output_buffer
|
10
|
+
@output_buffer = ActionView::OutputBuffer.new
|
11
|
+
@output_buffer << '['
|
12
|
+
yield
|
13
|
+
@output_buffer << ']'
|
14
|
+
@output_buffer
|
15
|
+
ensure
|
16
|
+
@output_buffer = buf
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is registered for .erb files" do
|
20
|
+
assert_equal Tilt::RailsERBTemplate, Tilt['spec/template.erb']
|
21
|
+
end
|
22
|
+
|
23
|
+
it "renders the template returned by the indirection" do
|
24
|
+
Tilt.new('spec/template.erb').render(self).chomp.must_equal "t1[<t2><t3>]t4"
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tilt-rails_erb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeremy Evans
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-19 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: actionpack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: |
|
56
|
+
tilt-rails_erb adds supports ERB templates using Rails' ERB handler,
|
57
|
+
which is different than standard ERB in that it supports using
|
58
|
+
<tt><%= foo do %><% end %></tt> syntax and it auto-escapes output.
|
59
|
+
email: code@jeremyevans.net
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- CHANGELOG
|
65
|
+
- MIT-LICENSE
|
66
|
+
- README.rdoc
|
67
|
+
- Rakefile
|
68
|
+
- lib/tilt/rails_erb.rb
|
69
|
+
- spec/template.erb
|
70
|
+
- spec/tilt_rails_erb_spec.rb
|
71
|
+
homepage: https://github.com/jeremyevans/tilt-rails_erb
|
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.5.1
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Adds support for Rails' ERB templates to Tilt
|
95
|
+
test_files: []
|