capcode-render-mustache 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 glejeune
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ = capcode-render-mustache
2
+
3
+ Capcode plugin to render via Mustache
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "capcode-render-mustache"
8
+ gem.summary = %Q{Capcode plugin to render via Mustache}
9
+ gem.description = gem.summary
10
+ gem.email = "gregoire.lejeune@free.fr"
11
+ gem.homepage = "http://github.com/glejeune/Capcode.more/tree/master/%s" % gem.name
12
+ gem.authors = ["Gregoire Lejeune"]
13
+
14
+ gem.add_dependency('mustache')
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,48 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{capcode-render-mustache}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Gregoire Lejeune"]
12
+ s.date = %q{2010-01-07}
13
+ s.description = %q{Capcode plugin to render via Mustache}
14
+ s.email = %q{gregoire.lejeune@free.fr}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ "LICENSE",
20
+ "README.rdoc",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "capcode-render-mustache.gemspec",
24
+ "examples/mustache/with_class.mustache",
25
+ "examples/mustache/without_class.mustache",
26
+ "examples/render-mustache.rb",
27
+ "lib/capcode/render/mustache.rb"
28
+ ]
29
+ s.homepage = %q{http://github.com/glejeune/Capcode.more/tree/master/capcode-render-mustache}
30
+ s.rdoc_options = ["--charset=UTF-8"]
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = %q{1.3.5}
33
+ s.summary = %q{Capcode plugin to render via Mustache}
34
+
35
+ if s.respond_to? :specification_version then
36
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
37
+ s.specification_version = 3
38
+
39
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
40
+ s.add_runtime_dependency(%q<mustache>, [">= 0"])
41
+ else
42
+ s.add_dependency(%q<mustache>, [">= 0"])
43
+ end
44
+ else
45
+ s.add_dependency(%q<mustache>, [">= 0"])
46
+ end
47
+ end
48
+
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <head>
3
+ <title>Capcode render with mustache ;)</title>
4
+ </head>
5
+ <body>
6
+ Bonjour, il est {{time}}
7
+ </body>
8
+ </html>
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <head>
3
+ <title>Capcode render with mustache ;)</title>
4
+ </head>
5
+ <body>
6
+ Bonjour, il est {{time}}
7
+ </body>
8
+ </html>
@@ -0,0 +1,31 @@
1
+ require 'rubygems'
2
+ require 'capcode'
3
+ $:.unshift( "../lib" )
4
+ require 'capcode/render/mustache'
5
+
6
+ module Capcode
7
+ set :mustache, "mustache"
8
+
9
+ class Index < Route '/'
10
+ def get
11
+ @time = Time.now
12
+ render :mustache => :with_class
13
+ end
14
+ end
15
+
16
+ class WithoutClass < Route '/without'
17
+ def get
18
+ render :mustache => :without_class, :time => Time.now
19
+ end
20
+ end
21
+ end
22
+
23
+ module Capcode::Views
24
+ class WithClass < Mustache
25
+ def time
26
+ @time
27
+ end
28
+ end
29
+ end
30
+
31
+ Capcode.run( )
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'mustache'
3
+ rescue LoadError => e
4
+ raise MissingLibrary, "Mustache could not be loaded (is it installed?): #{e.message}"
5
+ end
6
+
7
+ module Capcode
8
+ module Helpers
9
+ def render_mustache( f, opts = {} ) #:nodoc:
10
+ mustache_path = Capcode::Configuration.get( :mustache ) || Capcode.static()
11
+
12
+ name = Mustache.classify(f.to_s)
13
+
14
+ if Capcode::Views.const_defined?(name)
15
+ klass = Capcode::Views.const_get(name)
16
+ else
17
+ klass = Mustache
18
+ klass.template_file = mustache_path + "/" + f.to_s + ".mustache"
19
+ end
20
+
21
+ klass.template_extension = 'mustache'
22
+ klass.template_path = mustache_path
23
+
24
+ instance = klass.new
25
+
26
+ instance_variables.each do |name|
27
+ instance.instance_variable_set(name, instance_variable_get(name))
28
+ end
29
+
30
+ opts.each do |k, v|
31
+ instance[k] = v
32
+ end
33
+
34
+ instance.to_html
35
+ end
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capcode-render-mustache
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gregoire Lejeune
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-07 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mustache
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: Capcode plugin to render via Mustache
26
+ email: gregoire.lejeune@free.fr
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.rdoc
33
+ files:
34
+ - LICENSE
35
+ - README.rdoc
36
+ - Rakefile
37
+ - VERSION
38
+ - capcode-render-mustache.gemspec
39
+ - examples/mustache/with_class.mustache
40
+ - examples/mustache/without_class.mustache
41
+ - examples/render-mustache.rb
42
+ - lib/capcode/render/mustache.rb
43
+ has_rdoc: true
44
+ homepage: http://github.com/glejeune/Capcode.more/tree/master/capcode-render-mustache
45
+ licenses: []
46
+
47
+ post_install_message:
48
+ rdoc_options:
49
+ - --charset=UTF-8
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ requirements: []
65
+
66
+ rubyforge_project:
67
+ rubygems_version: 1.3.5
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Capcode plugin to render via Mustache
71
+ test_files: []
72
+