tilt-mustache 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +1 -0
- data/Rakefile +28 -0
- data/lib/tilt-mustache.rb +19 -0
- data/test/helper.rb +4 -0
- data/test/test_mustache.rb +27 -0
- data/tilt-mustache.gemspec +18 -0
- metadata +115 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# tilt-mustache
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems' unless defined?(Gem)
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
%w(install release).each do |task|
|
7
|
+
Rake::Task[task].enhance do
|
8
|
+
sh "rm -rf pkg"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'Bump version on github'
|
13
|
+
task :bump do
|
14
|
+
if `git status -s`.strip == ''
|
15
|
+
puts "\e[31mNothing to commit (working directory clean)\e[0m"
|
16
|
+
else
|
17
|
+
version = Bundler.load_gemspec(Dir[File.expand_path('../*.gemspec', __FILE__)].first).version
|
18
|
+
sh "git add .; git commit -a -m \"Bump to version #{version}\""
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Rake::TestTask.new(:test) do |t|
|
23
|
+
t.test_files = Dir['test/**/test_*.rb']
|
24
|
+
t.verbose = true
|
25
|
+
end
|
26
|
+
|
27
|
+
task :release => :bump
|
28
|
+
task :default => :test
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'tilt' unless defined? Tilt
|
2
|
+
|
3
|
+
module Tilt
|
4
|
+
# Mustache template
|
5
|
+
# https://github.com/defunkt/mustache
|
6
|
+
class MustacheTemplate < Template
|
7
|
+
def initialize_engine
|
8
|
+
return if defined? ::Mustache
|
9
|
+
require_template_library 'mustache'
|
10
|
+
end
|
11
|
+
|
12
|
+
def prepare; end
|
13
|
+
|
14
|
+
def evaluate(scope, locals, &block)
|
15
|
+
Mustache.render(data, locals.merge(scope.is_a?(Hash) ? scope : {}).merge({:yield => block.nil? ? '' : block.call}))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
register 'mustache', MustacheTemplate
|
19
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
describe Tilt::MustacheTemplate do
|
4
|
+
it "registered for '.mustache' files" do
|
5
|
+
assert_equal Tilt::MustacheTemplate, Tilt["test.mustache"]
|
6
|
+
end
|
7
|
+
|
8
|
+
it "loading and evaluating templates on #render" do
|
9
|
+
template = Tilt::MustacheTemplate.new { |t| "Hello World!" }
|
10
|
+
assert_equal "Hello World!", template.render
|
11
|
+
end
|
12
|
+
|
13
|
+
it "passing locals" do
|
14
|
+
template = Tilt::MustacheTemplate.new { "Hey {{name}}!" }
|
15
|
+
assert_equal "Hey Joe!", template.render(nil, :name => 'Joe')
|
16
|
+
end
|
17
|
+
|
18
|
+
it "evaluating in an object scope" do
|
19
|
+
template = Tilt::MustacheTemplate.new { 'Hey {{name}}!' }
|
20
|
+
assert_equal "Hey Joe!", template.render({:name => 'Joe'})
|
21
|
+
end
|
22
|
+
|
23
|
+
it "passing a block for yield" do
|
24
|
+
template = Tilt::MustacheTemplate.new { 'Hey {{yield}}!' }
|
25
|
+
assert_equal "Hey Joe!", template.render { 'Joe' }
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "tilt-mustache"
|
3
|
+
s.version = "0.0.1"
|
4
|
+
s.date = "2012-01-04"
|
5
|
+
s.platform = Gem::Platform::RUBY
|
6
|
+
s.authors = ["Davide D'Agostino"]
|
7
|
+
s.email = "d.dagostino@lipsiasoft.com"
|
8
|
+
s.homepage = "http://github.com/daddye/tilt-mustache"
|
9
|
+
s.summary = %q{Add Mustache to Tilt}
|
10
|
+
s.description = %q{Add Mustache to Tilt}
|
11
|
+
|
12
|
+
s.add_dependency 'tilt'
|
13
|
+
s.add_dependency 'mustache'
|
14
|
+
s.add_development_dependency 'minitest'
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tilt-mustache
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Davide D'Agostino
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-01-04 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: tilt
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: mustache
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: minitest
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
description: Add Mustache to Tilt
|
64
|
+
email: d.dagostino@lipsiasoft.com
|
65
|
+
executables: []
|
66
|
+
|
67
|
+
extensions: []
|
68
|
+
|
69
|
+
extra_rdoc_files: []
|
70
|
+
|
71
|
+
files:
|
72
|
+
- .gitignore
|
73
|
+
- Gemfile
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- lib/tilt-mustache.rb
|
77
|
+
- test/helper.rb
|
78
|
+
- test/test_mustache.rb
|
79
|
+
- tilt-mustache.gemspec
|
80
|
+
has_rdoc: true
|
81
|
+
homepage: http://github.com/daddye/tilt-mustache
|
82
|
+
licenses: []
|
83
|
+
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
version: "0"
|
107
|
+
requirements: []
|
108
|
+
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 1.6.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 3
|
113
|
+
summary: Add Mustache to Tilt
|
114
|
+
test_files: []
|
115
|
+
|