Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated to latest temple version

  • Loading branch information...
commit 4f3fcc8a92fe560b4a0245a48a5e35ef5a8eb197 1 parent 7e88404
@Papipo authored
View
7 Gemfile.lock
@@ -5,6 +5,7 @@ PATH
nokogiri
temple
tilt
+ tongo
GEM
remote: http://rubygems.org/
@@ -22,12 +23,12 @@ GEM
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
rspec-mocks (~> 2.5.0)
- rspec-core (2.5.1)
+ rspec-core (2.5.2)
rspec-expectations (2.5.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.5.0)
- temple (0.1.8)
- tilt (1.2.2)
+ temple (0.2.0)
+ tilt (1.3)
PLATFORMS
ruby
View
4 lib/tongo/engine.rb
@@ -1,7 +1,9 @@
module Tongo
class Engine < Temple::Engine
use Tongo::Parser
- use Temple::Filters::MultiFlattener
+ filter :MultiFlattener
+ filter :StaticMerger
+ filter :DynamicInliner
use Tongo::Generator
end
end
View
2  lib/tongo/generator.rb
@@ -4,7 +4,7 @@ class Generator
TOKENIZER = /(\%\{.+?\})/
INTERPOLATION = /\%\{(.+?)\}/
- def compile(exp)
+ def call(exp)
"\"#{compile!(exp)}\""
end
View
8 lib/tongo/parser.rb
@@ -1,6 +1,8 @@
module Tongo
class Parser
- def compile(src)
+ attr_reader :ns
+
+ def call(src)
src = "<root xmlns:#{@ns}=\"http://blog.codecaster.es\">#{src}</root>"
doc = Nokogiri::XML::DocumentFragment.parse(src)
traverse_children(doc.children)
@@ -28,10 +30,6 @@ def handle_node(node)
end
end
- def ns
- @ns
- end
-
def nested_node(e)
(is_tongo?(e) ? tongo(e, true) : html(e)) << traverse_children(e)
end
View
8 lib/tongo/template.rb
@@ -1,7 +1,3 @@
module Tongo
- class Template < Temple::Template
- engine Tongo::Engine
- end
-end
-
-Tilt.register 'tng', Tongo::Template
+ Template = Temple::Templates::Tilt(Tongo::Engine, :register_as => 'tng')
+end
View
4 spec/unit/tongo_parser_spec.rb
@@ -3,7 +3,7 @@
describe Tongo::Parser do
def compiled(src)
- Tongo::Parser.new.compile(src)
+ Tongo::Parser.new.call(src)
end
it { compiled("Plain text").should == [:multi, [:text, "Plain text"]] }
@@ -27,5 +27,5 @@ def compiled(src)
end
describe Tongo::Parser, "with a custom namespace" do
- it { Tongo::Parser.new(:ns => 'pop').compile('<pop:custom />').should == [:multi, [:empty, 'custom', {}]] }
+ it { Tongo::Parser.new(:ns => 'pop').call('<pop:custom />').should == [:multi, [:empty, 'custom', {}]] }
end
Please sign in to comment.
Something went wrong with that request. Please try again.