starapor-slippers 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +35 -0
- data/Rakefile +61 -0
- data/VERSION.yml +4 -0
- data/examples/blog/README +3 -0
- data/examples/blog/blog.db +0 -0
- data/examples/blog/controller/main.rb +29 -0
- data/examples/blog/model/entry.rb +30 -0
- data/examples/blog/public/styles/blog.css +132 -0
- data/examples/blog/spec/blog.rb +87 -0
- data/examples/blog/start.rb +7 -0
- data/examples/blog/view/edit.st +17 -0
- data/examples/blog/view/edit.xhtml +17 -0
- data/examples/blog/view/entry.st +12 -0
- data/examples/blog/view/index.st +4 -0
- data/examples/blog/view/index.xhtml +17 -0
- data/examples/blog/view/layout.st +11 -0
- data/examples/blog/view/layout.xhtml +11 -0
- data/examples/blog/view/new.st +16 -0
- data/examples/blog/view/new.xhtml +16 -0
- data/examples/main_controller.rb +16 -0
- data/examples/start.rb +7 -0
- data/examples/todolist/README +1 -0
- data/examples/todolist/public/favicon.ico +0 -0
- data/examples/todolist/public/js/jquery.js +1923 -0
- data/examples/todolist/public/ramaze.png +0 -0
- data/examples/todolist/spec/todolist.rb +133 -0
- data/examples/todolist/src/controller/main.rb +71 -0
- data/examples/todolist/src/element/page.rb +31 -0
- data/examples/todolist/src/model.rb +14 -0
- data/examples/todolist/start.rb +11 -0
- data/examples/todolist/template/index.st +39 -0
- data/examples/todolist/template/index.xhtml +17 -0
- data/examples/todolist/template/new.st +41 -0
- data/examples/todolist/template/new.xhtml +7 -0
- data/examples/todolist/template/tasks.st +6 -0
- data/examples/todolist/todolist.db +7 -0
- data/examples/todolist.db +5 -0
- data/examples/view/index.st +8 -0
- data/examples/view/person/age.st +1 -0
- data/examples/view/person/index.st +2 -0
- data/examples/view/person/name.st +1 -0
- data/lib/engine/binding_wrapper.rb +10 -0
- data/lib/engine/engine.rb +26 -0
- data/lib/engine/file_template.rb +12 -0
- data/lib/engine/slippers.treetop +109 -0
- data/lib/engine/slippers_nodes.rb +90 -0
- data/lib/engine/template.rb +17 -0
- data/lib/engine/template_group.rb +20 -0
- data/lib/engine/template_group_directory.rb +39 -0
- data/lib/ramazeTemplates/0001-SarahTaraporewalla-adding-new-template-file-for-sli.patch +25 -0
- data/lib/ramazeTemplates/slippers.rb +25 -0
- data/lib/slippers.rb +14 -0
- data/spec/binding_wrapper.rb +14 -0
- data/spec/engine.rb +76 -0
- data/spec/file_template.rb +9 -0
- data/spec/parser.rb +111 -0
- data/spec/person_template.st +1 -0
- data/spec/slippers_spec.rb +5 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/template_group.rb +24 -0
- data/spec/template_group_directory.rb +38 -0
- data/spec/views/index.st +1 -0
- data/spec/views/money.rb +2 -0
- data/spec/views/person/age.st +1 -0
- data/spec/views/person/date_renderer.rb +5 -0
- data/spec/views/person/name.st +1 -0
- metadata +151 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
module Slippers
|
2
|
+
class TemplateGroup
|
3
|
+
def initialize(params={})
|
4
|
+
@templates = params[:templates]
|
5
|
+
@super_group = params[:super_group]
|
6
|
+
end
|
7
|
+
|
8
|
+
def find(subtemplate)
|
9
|
+
return nil unless @templates
|
10
|
+
return @templates[subtemplate.to_sym] if @templates.include?(subtemplate.to_sym)
|
11
|
+
find_in_super_group(subtemplate)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def find_in_super_group(subtemplate)
|
16
|
+
return nil unless @super_group
|
17
|
+
@super_group.find(subtemplate)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Slippers
|
2
|
+
class TemplateGroupDirectory < TemplateGroup
|
3
|
+
def initialize(directory_path, params={})
|
4
|
+
@directory_path = directory_path
|
5
|
+
@super_group = params[:super_group]
|
6
|
+
end
|
7
|
+
attr_reader :directory_path
|
8
|
+
|
9
|
+
def find(subtemplate)
|
10
|
+
|
11
|
+
file_name = @directory_path + '/' + subtemplate + '.st'
|
12
|
+
return find_renderer(subtemplate) unless File.exist?(file_name)
|
13
|
+
Engine.new(FileTemplate.new(file_name).template, :template_group => self)
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def eql?(other)
|
18
|
+
return false unless other
|
19
|
+
directory_path.eql?(other.directory_path)
|
20
|
+
end
|
21
|
+
def hash
|
22
|
+
@directory_path.hash
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def find_renderer(subtemplate)
|
27
|
+
file_name = @directory_path + '/' + subtemplate + '.rb'
|
28
|
+
return find_in_super_group(subtemplate) unless File.exist?(file_name)
|
29
|
+
renderer_name = subtemplate.split('/')[-1]
|
30
|
+
load File.expand_path(file_name)
|
31
|
+
renderer_name.camelize.constantize.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def find_in_super_group(subtemplate)
|
35
|
+
return nil unless @super_group
|
36
|
+
@super_group.find(subtemplate)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
From 5a6c869d4709ce84d7c07b5dd33cf06e39c0111e Mon Sep 17 00:00:00 2001
|
2
|
+
From: Sarah Taraporewalla <sarah.tarap@gmail.com>
|
3
|
+
Date: Mon, 16 Feb 2009 20:44:08 +0000
|
4
|
+
Subject: [PATCH] SarahTaraporewalla: adding new template file for slippers template engine
|
5
|
+
|
6
|
+
---
|
7
|
+
lib/ramaze/template.rb | 2 +-
|
8
|
+
1 files changed, 1 insertions(+), 1 deletions(-)
|
9
|
+
|
10
|
+
diff --git a/lib/ramaze/template.rb b/lib/ramaze/template.rb
|
11
|
+
index 096816b..99f1f94 100644
|
12
|
+
--- a/lib/ramaze/template.rb
|
13
|
+
+++ b/lib/ramaze/template.rb
|
14
|
+
@@ -18,7 +18,7 @@ module Ramaze
|
15
|
+
|
16
|
+
AVAILABLE_ENGINES = %w[
|
17
|
+
Amrita2 Builder Erubis Haml Liquid Markaby Maruku Nagoro None RedCloth
|
18
|
+
- Remarkably Sass Tagz Tenjin XSLT
|
19
|
+
+ Remarkably Sass Slippers Tagz Tenjin XSLT
|
20
|
+
]
|
21
|
+
|
22
|
+
AVAILABLE_ENGINES.each do |const|
|
23
|
+
--
|
24
|
+
1.6.1
|
25
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require '/Users/starapor/Development/slippers/slippers'
|
2
|
+
|
3
|
+
module Ramaze
|
4
|
+
module Template
|
5
|
+
class Slippers < Template
|
6
|
+
|
7
|
+
ENGINES[self] = %w[ st ]
|
8
|
+
class << self
|
9
|
+
def transform(action)
|
10
|
+
slippers = wrap_compile(action)
|
11
|
+
object_to_render = ::Slippers::BindingWrapper.new(action.binding)
|
12
|
+
slippers.render(object_to_render)
|
13
|
+
end
|
14
|
+
|
15
|
+
def compile(action, template)
|
16
|
+
subtemplates = action.controller.trait[:slippers_options] || {}
|
17
|
+
|
18
|
+
template_group_directory = ::Slippers::TemplateGroupDirectory.new(Global.view_root)
|
19
|
+
template_group = ::Slippers::TemplateGroup.new(:super_group => template_group_directory, :templates => subtemplates)
|
20
|
+
::Slippers::Engine.new(template, :template_group => template_group)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/slippers.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'treetop'
|
3
|
+
require 'active_support'
|
4
|
+
|
5
|
+
require File.dirname(__FILE__) + '/engine/template'
|
6
|
+
require File.dirname(__FILE__) + '/engine/file_template'
|
7
|
+
require File.dirname(__FILE__) + '/engine/template_group'
|
8
|
+
require File.dirname(__FILE__) + '/engine/template_group_directory'
|
9
|
+
require File.dirname(__FILE__) + '/engine/engine'
|
10
|
+
require File.dirname(__FILE__) + '/engine/binding_wrapper'
|
11
|
+
require File.dirname(__FILE__) + '/engine/slippers_nodes'
|
12
|
+
|
13
|
+
|
14
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Slippers::BindingWrapper do
|
4
|
+
def f
|
5
|
+
@a = 22
|
6
|
+
@b = 33
|
7
|
+
binding
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should evaluate the bindings" do
|
11
|
+
bindings_wrapper = Slippers::BindingWrapper.new(f())
|
12
|
+
bindings_wrapper['a'].should eql(22)
|
13
|
+
end
|
14
|
+
end
|
data/spec/engine.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Slippers::Engine do
|
4
|
+
before do
|
5
|
+
template = 'Hello $first$ $last$'
|
6
|
+
@engine = Slippers::Engine.new(template)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should render a template without any holes" do
|
10
|
+
template = "This is a string without any holes in it"
|
11
|
+
engine = Slippers::Engine.new(template)
|
12
|
+
engine.render.should eql("This is a string without any holes in it")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should fill in a hole within a template" do
|
16
|
+
template = "This is a string with a message of $message$"
|
17
|
+
engine = Slippers::Engine.new(template)
|
18
|
+
engine.render(:message => "hello world").should eql("This is a string with a message of hello world")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should render a subtemplate within a template" do
|
22
|
+
subtemplate = Slippers::Engine.new("this is a subtemplate")
|
23
|
+
template_group = Slippers::TemplateGroup.new(:templates => {:message => subtemplate})
|
24
|
+
template = "This is a template and then $message()$"
|
25
|
+
engine = Slippers::Engine.new(template, :template_group => template_group)
|
26
|
+
engine.render.should eql("This is a template and then this is a subtemplate")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should apply a template to an attribute" do
|
30
|
+
subtemplate = Slippers::Engine.new("this is a subtemplate with a message of $saying$")
|
31
|
+
template_group = Slippers::TemplateGroup.new(:templates => {:message_subtemplate => subtemplate})
|
32
|
+
template = "This is a template and then $message:message_subtemplate()$!"
|
33
|
+
engine = Slippers::Engine.new(template, :template_group => template_group)
|
34
|
+
engine.render(:message => {:saying => 'hello world'}).should eql("This is a template and then this is a subtemplate with a message of hello world!")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should apply an anonymous subtemplate to an attribute" do
|
38
|
+
template = "This is a template and then $message:{this is a subtemplate with a message of $saying$}$!"
|
39
|
+
engine = Slippers::Engine.new(template)
|
40
|
+
engine.render(:message => {:saying => 'hello world'}).should eql("This is a template and then this is a subtemplate with a message of hello world!")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should render a subtemplate using different rendering technologies" do
|
44
|
+
age_renderer = AgeRenderer.new
|
45
|
+
subtemplate = Slippers::Engine.new('$first$ $last$')
|
46
|
+
person = OpenStruct.new({:name => {:first => 'Fred', :last => 'Flinstone'}, :dob => Date.new(DateTime.now.year - 34, 2, 4)})
|
47
|
+
template_group = Slippers::TemplateGroup.new(:templates => {:name => subtemplate, :age => age_renderer})
|
48
|
+
engine = Slippers::Engine.new("Introducing $name:name()$ who is $dob:age()$.", :template_group => template_group)
|
49
|
+
engine.render(person).should eql("Introducing Fred Flinstone who is 34 years old.")
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should render a bindings wrapper' do
|
53
|
+
@first = 'fred'
|
54
|
+
@last = 'flinstone'
|
55
|
+
|
56
|
+
person_binding = Slippers::BindingWrapper.new(binding)
|
57
|
+
@engine.render(person_binding).should eql('Hello fred flinstone')
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should render a list of objects' do
|
61
|
+
subtemplate = Slippers::Engine.new('Hello $first$ $last$ ')
|
62
|
+
template_group = Slippers::TemplateGroup.new(:templates => {:person => subtemplate})
|
63
|
+
template = 'Say: $people:person()$'
|
64
|
+
@people = [OpenStruct.new({:first => 'fred', :last => 'flinstone'}), OpenStruct.new({:first => 'barney', :last => 'rubble'})]
|
65
|
+
|
66
|
+
engine = Slippers::Engine.new(template, :template_group => template_group)
|
67
|
+
engine.render(Slippers::BindingWrapper.new(binding)).should eql('Say: Hello fred flinstone Hello barney rubble ')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class AgeRenderer
|
72
|
+
def render(date)
|
73
|
+
age = DateTime.now.year - date.year
|
74
|
+
age.to_s + " years old"
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Slippers::FileTemplate, " when rendering" do
|
4
|
+
it "should read the template from a file" do
|
5
|
+
template_file = Slippers::FileTemplate.new('spec/person_template.st')
|
6
|
+
template_file.template.should eql('This is a $template$')
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
data/spec/parser.rb
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
class Person
|
4
|
+
def initialize(first, last)
|
5
|
+
@first, @last = first, last
|
6
|
+
end
|
7
|
+
attr_reader :first, :last
|
8
|
+
def to_s
|
9
|
+
first + ' ' + last
|
10
|
+
end
|
11
|
+
end
|
12
|
+
describe SlippersParser do
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
@parser = SlippersParser.new
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return the string unparsed when there are no keywords in it" do
|
19
|
+
@parser.parse('').eval(nil).should eql('')
|
20
|
+
@parser.parse(' ').eval(nil).should eql(' ')
|
21
|
+
@parser.parse('this should be returned unchanged').eval.should eql('this should be returned unchanged')
|
22
|
+
@parser.parse(' this should be returned unchanged ').eval.should eql(' this should be returned unchanged ')
|
23
|
+
@parser.parse('this should be 1234567890 ').eval.should eql('this should be 1234567890 ')
|
24
|
+
@parser.parse('this should be abc1234567890 ').eval.should eql('this should be abc1234567890 ')
|
25
|
+
@parser.parse('this should be !@£%^&*()').eval.should eql('this should be !@£%^&*()')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should find the keyword within the delimiters' do
|
29
|
+
message = OpenStruct.new({:message => 'the message', :name => 'fred'})
|
30
|
+
@parser.parse('$message$').eval(message).should eql('the message')
|
31
|
+
@parser.parse('$message$ for $name$').eval(message).should eql('the message for fred')
|
32
|
+
@parser.parse('we want to find $message$').eval(message).should eql('we want to find the message')
|
33
|
+
@parser.parse('$message$ has spoken').eval(message).should eql('the message has spoken')
|
34
|
+
@parser.parse('Yes! $message$ has spoken').eval(message).should eql('Yes! the message has spoken')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should parse the subtemplate found within the delimiters' do
|
38
|
+
template = Slippers::Engine.new('template for this')
|
39
|
+
template_with_underscore = Slippers::Engine.new('template with underscore')
|
40
|
+
template_group = Slippers::TemplateGroup.new(:templates => {:template => template, :template_with_underscore => template_with_underscore})
|
41
|
+
@parser.parse('$template()$').eval(nil, template_group).should eql('template for this')
|
42
|
+
@parser.parse('Stuff before $template()$ and after').eval(nil, template_group).should eql('Stuff before template for this and after')
|
43
|
+
@parser.parse('then there is $template_with_underscore()$').eval(nil, template_group).should eql('then there is template with underscore')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should parse an anonymous subtemplate' do
|
47
|
+
@parser.parse('$people:{template for this $name$}$').eval(:people => {:name => 'fred'}).should eql('template for this fred')
|
48
|
+
@parser.parse('${template for this $name$}$').eval(:name => 'fred').should eql('template for this fred')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should apply the attribute to a subtemplate when parsing it' do
|
52
|
+
subtemplate = Slippers::Engine.new('Hello $first$ $last$')
|
53
|
+
template_group = Slippers::TemplateGroup.new(:templates => {:person => subtemplate})
|
54
|
+
person = OpenStruct.new({:name => OpenStruct.new({:first => 'fred', :last => 'flinstone'})})
|
55
|
+
@parser.parse('$name:person()$').eval(person, template_group).should eql('Hello fred flinstone')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should not match on escaped delimiters' do
|
59
|
+
#@parser.parse('stuff \$notmatched\$').eval.should eql('stuff \$notmatched\$')
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should render a list of objects" do
|
63
|
+
people = [OpenStruct.new({:name => 'fred'}), OpenStruct.new({:name => 'barney'}) ]
|
64
|
+
@parser.parse('this is $name$').eval(people).should eql("this is fredbarney")
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should apply a list of objects to subtemplates" do
|
68
|
+
people = [ Person.new('fred', 'flinstone'), Person.new('barney', 'rubble') ]
|
69
|
+
subtemplate = Slippers::Engine.new('this is $first$ $last$ ')
|
70
|
+
template_group = Slippers::TemplateGroup.new(:templates => {:person => subtemplate})
|
71
|
+
object_to_render = OpenStruct.new({:people => people})
|
72
|
+
|
73
|
+
@parser.parse('$people:person()$').eval(object_to_render, template_group).should eql("this is fred flinstone this is barney rubble ")
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should substitue in an empty string when the subtemplate cannot be found" do
|
77
|
+
person = OpenStruct.new({:name => 'red'})
|
78
|
+
@parser.parse("This is the unknown template $name:unknown()$!").eval(person).should eql("This is the unknown template !")
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should substitute in an empty string when the attribute cannot be found" do
|
82
|
+
@parser.parse("This is the $adjective$ template with $message$.").eval(OpenStruct.new).should eql("This is the template with .")
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should parse the file template from the template group" do
|
86
|
+
template_group = Slippers::TemplateGroupDirectory.new('spec/views')
|
87
|
+
name = OpenStruct.new({:first => 'fred', :last => 'flinestone'})
|
88
|
+
people = OpenStruct.new({:fred => name})
|
89
|
+
@parser.parse("should parse $person/name()$").eval(name, template_group).should eql("should parse fred flinestone")
|
90
|
+
@parser.parse("should parse $fred:person/name()$").eval(people, template_group).should eql("should parse fred flinestone")
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should convert attribute to string" do
|
94
|
+
fred = OpenStruct.new({:name => 'fred', :dob => DateTime.new(1983, 1, 2)})
|
95
|
+
template_group = Slippers::TemplateGroup.new(:templates => {:date => Slippers::Engine.new('$year$')} )
|
96
|
+
@parser.parse("This is $name$ who was born in $dob:date()$").eval(fred, template_group).should eql('This is fred who was born in 1983')
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should render a hash" do
|
100
|
+
hash_object = {:title => 'Domain driven design', :author => 'Eric Evans'}
|
101
|
+
@parser.parse("should parse $title$ by $author$").eval(hash_object).should eql("should parse Domain driven design by Eric Evans")
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should return an empty string if the subtemplate does not respond to render' do
|
105
|
+
template_group = Slippers::TemplateGroup.new(:templates => {:not_a_renderer => stub('renderer')})
|
106
|
+
@parser.parse("$not_a_renderer()$").eval(stub('object'), template_group).should eql('')
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
This is a $template$
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Slippers::TemplateGroup do
|
4
|
+
it 'should find the right template' do
|
5
|
+
subtemplate = Slippers::Engine.new('Hello $first$ $last$')
|
6
|
+
template_group = Slippers::TemplateGroup.new(:templates => {:person => subtemplate})
|
7
|
+
template_group.find(:person).should eql(subtemplate)
|
8
|
+
template_group.find('person').should eql(subtemplate)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should return nil if it cannot find the right template' do
|
12
|
+
template_group = Slippers::TemplateGroup.new()
|
13
|
+
template_group.find(:not_this).should eql(nil)
|
14
|
+
template_group.find('not_this').should eql(nil)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should look in the super template group if it cannot find the template' do
|
18
|
+
template = stub 'template'
|
19
|
+
super_template_group = Slippers::TemplateGroup.new(:templates => {:person => template})
|
20
|
+
template_group = Slippers::TemplateGroup.new(:templates => {}, :super_group => super_template_group)
|
21
|
+
template_group.find(:person).should eql(template)
|
22
|
+
template_group.find(:not_this).should eql(nil)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Slippers::TemplateGroupDirectory do
|
4
|
+
|
5
|
+
it 'should find the file in the directory folder' do
|
6
|
+
template_group = Slippers::TemplateGroupDirectory.new('spec/views')
|
7
|
+
template_group.find('index').should eql(Slippers::Engine.new('Hey foo', :template_group => template_group))
|
8
|
+
template_group.find('person/age').should eql(Slippers::Engine.new('The age for him is $age$', :template_group => template_group))
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should return nil if it cannot find the file in the directory folder' do
|
12
|
+
template_group = Slippers::TemplateGroupDirectory.new('spec/views')
|
13
|
+
template_group.find('person/not_found').should eql(nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should read the st template file and return a new slipers engine for it' do
|
17
|
+
template_group = Slippers::TemplateGroupDirectory.new('spec/views')
|
18
|
+
template_group.find('index').should eql(Slippers::Engine.new('Hey foo', :template_group => template_group))
|
19
|
+
template_group.find('person/age').should eql(Slippers::Engine.new('The age for him is $age$', :template_group => template_group))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should load the ruby file found in the directory folder' do
|
23
|
+
template_group = Slippers::TemplateGroupDirectory.new('spec/views')
|
24
|
+
template_group.find('person/date_renderer').class.should eql(DateRenderer)
|
25
|
+
template_group.find('money').class.should eql(Money)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should look in the super template group if it cannot find the template' do
|
29
|
+
template = stub 'template'
|
30
|
+
super_template_group = Slippers::TemplateGroup.new(:templates => {:person => template})
|
31
|
+
template_group = Slippers::TemplateGroupDirectory.new('spec/views', :super_group => super_template_group)
|
32
|
+
template_group.find('person').should eql(template)
|
33
|
+
template_group.find('not_this').should eql(nil)
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
end
|
data/spec/views/index.st
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Hey foo
|
data/spec/views/money.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
The age for him is $age$
|
@@ -0,0 +1 @@
|
|
1
|
+
$first$ $last$
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: starapor-slippers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sarah Taraporewalla
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-25 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: schacon-git
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: A strict templating library for ruby
|
26
|
+
email: me@sarahtaraporewalla.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files: []
|
32
|
+
|
33
|
+
files:
|
34
|
+
- LICENSE
|
35
|
+
- Rakefile
|
36
|
+
- README
|
37
|
+
- VERSION.yml
|
38
|
+
- lib/engine
|
39
|
+
- lib/engine/binding_wrapper.rb
|
40
|
+
- lib/engine/engine.rb
|
41
|
+
- lib/engine/file_template.rb
|
42
|
+
- lib/engine/slippers.treetop
|
43
|
+
- lib/engine/slippers_nodes.rb
|
44
|
+
- lib/engine/template.rb
|
45
|
+
- lib/engine/template_group.rb
|
46
|
+
- lib/engine/template_group_directory.rb
|
47
|
+
- lib/ramazeTemplates
|
48
|
+
- lib/ramazeTemplates/0001-SarahTaraporewalla-adding-new-template-file-for-sli.patch
|
49
|
+
- lib/ramazeTemplates/slippers.rb
|
50
|
+
- lib/slippers.rb
|
51
|
+
- spec/binding_wrapper.rb
|
52
|
+
- spec/engine.rb
|
53
|
+
- spec/file_template.rb
|
54
|
+
- spec/parser.rb
|
55
|
+
- spec/person_template.st
|
56
|
+
- spec/slippers_spec.rb
|
57
|
+
- spec/spec_helper.rb
|
58
|
+
- spec/template_group.rb
|
59
|
+
- spec/template_group_directory.rb
|
60
|
+
- spec/views
|
61
|
+
- spec/views/index.st
|
62
|
+
- spec/views/money.rb
|
63
|
+
- spec/views/person
|
64
|
+
- spec/views/person/age.st
|
65
|
+
- spec/views/person/date_renderer.rb
|
66
|
+
- spec/views/person/name.st
|
67
|
+
- examples/blog
|
68
|
+
- examples/blog/blog.db
|
69
|
+
- examples/blog/controller
|
70
|
+
- examples/blog/controller/main.rb
|
71
|
+
- examples/blog/model
|
72
|
+
- examples/blog/model/entry.rb
|
73
|
+
- examples/blog/public
|
74
|
+
- examples/blog/public/styles
|
75
|
+
- examples/blog/public/styles/blog.css
|
76
|
+
- examples/blog/README
|
77
|
+
- examples/blog/spec
|
78
|
+
- examples/blog/spec/blog.rb
|
79
|
+
- examples/blog/start.rb
|
80
|
+
- examples/blog/view
|
81
|
+
- examples/blog/view/edit.st
|
82
|
+
- examples/blog/view/edit.xhtml
|
83
|
+
- examples/blog/view/entry.st
|
84
|
+
- examples/blog/view/index.st
|
85
|
+
- examples/blog/view/index.xhtml
|
86
|
+
- examples/blog/view/layout.st
|
87
|
+
- examples/blog/view/layout.xhtml
|
88
|
+
- examples/blog/view/new.st
|
89
|
+
- examples/blog/view/new.xhtml
|
90
|
+
- examples/main_controller.rb
|
91
|
+
- examples/start.rb
|
92
|
+
- examples/todolist
|
93
|
+
- examples/todolist/public
|
94
|
+
- examples/todolist/public/favicon.ico
|
95
|
+
- examples/todolist/public/js
|
96
|
+
- examples/todolist/public/js/jquery.js
|
97
|
+
- examples/todolist/public/ramaze.png
|
98
|
+
- examples/todolist/Rakefile
|
99
|
+
- examples/todolist/README
|
100
|
+
- examples/todolist/spec
|
101
|
+
- examples/todolist/spec/todolist.rb
|
102
|
+
- examples/todolist/src
|
103
|
+
- examples/todolist/src/controller
|
104
|
+
- examples/todolist/src/controller/main.rb
|
105
|
+
- examples/todolist/src/element
|
106
|
+
- examples/todolist/src/element/page.rb
|
107
|
+
- examples/todolist/src/model.rb
|
108
|
+
- examples/todolist/start.rb
|
109
|
+
- examples/todolist/template
|
110
|
+
- examples/todolist/template/index.st
|
111
|
+
- examples/todolist/template/index.xhtml
|
112
|
+
- examples/todolist/template/new.st
|
113
|
+
- examples/todolist/template/new.xhtml
|
114
|
+
- examples/todolist/template/tasks.st
|
115
|
+
- examples/todolist/todolist.db
|
116
|
+
- examples/todolist.db
|
117
|
+
- examples/view
|
118
|
+
- examples/view/index.st
|
119
|
+
- examples/view/person
|
120
|
+
- examples/view/person/age.st
|
121
|
+
- examples/view/person/index.st
|
122
|
+
- examples/view/person/name.st
|
123
|
+
has_rdoc: true
|
124
|
+
homepage: http://github.com/starapor/slippers
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options:
|
127
|
+
- --inline-source
|
128
|
+
- --charset=UTF-8
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: "0"
|
136
|
+
version:
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: "0"
|
142
|
+
version:
|
143
|
+
requirements: []
|
144
|
+
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 1.2.0
|
147
|
+
signing_key:
|
148
|
+
specification_version: 2
|
149
|
+
summary: A strict templating library for Ruby
|
150
|
+
test_files: []
|
151
|
+
|