Skip to content
Browse files

Template inheritance engine is now in separated template inheritance gem

  • Loading branch information...
1 parent 716da25 commit 376fad8cbe6e1673d40c10ced269526ecca732a8 Jakub Šťastný aka Botanicus committed Oct 2, 2010
Showing with 70 additions and 585 deletions.
  1. +1 −1 lib/rango/mixins/conventional_rendering.rb
  2. +48 −0 lib/rango/router/adapters/http_router.rb
  3. +9 −0 lib/rango/template.rb
  4. +0 −33 lib/rango/templates/exts/haml.rb
  5. +0 −29 lib/rango/templates/exts/tilt.rb
  6. +0 −147 lib/rango/templates/helpers.rb
  7. +0 −87 lib/rango/templates/template.rb
  8. +1 −1 lib/rango/version.rb
  9. +2 −2 spec/rango/mixins/render_spec.rb
  10. 0 spec/rango/templates/exts/haml_spec.rb
  11. 0 spec/rango/templates/exts/tilt_spec.rb
  12. +0 −139 spec/rango/templates/helpers_spec.rb
  13. +0 −61 spec/rango/templates/template_spec.rb
  14. +7 −6 spec/rango_spec.rb
  15. +0 −2 spec/stubs/templates/block/block.html.haml
  16. +0 −5 spec/stubs/templates/block/blocks.html.haml
  17. +0 −2 spec/stubs/templates/block/error.html.haml
  18. +0 −3 spec/stubs/templates/block/getter.html.haml
  19. +0 −1 spec/stubs/templates/block/value.html.haml
  20. +0 −1 spec/stubs/templates/context_id.html.haml
  21. +0 −5 spec/stubs/templates/enhance_block/basic.html.haml
  22. +0 −3 spec/stubs/templates/enhance_block/error.html.haml
  23. +0 −1 spec/stubs/templates/enhance_block/name_error.html.haml
  24. +0 −3 spec/stubs/templates/enhance_block/nil.html.haml
  25. +0 −2 spec/stubs/templates/enhance_block/standalone.html.haml
  26. +0 −5 spec/stubs/templates/extend_block/basic.html.haml
  27. +0 −5 spec/stubs/templates/extend_block/error.html.haml
  28. +0 −1 spec/stubs/templates/extend_block/error2.html.haml
  29. +0 −1 spec/stubs/templates/extend_block/name_error.html.haml
  30. +0 −4 spec/stubs/templates/extend_block/nil.html.haml
  31. +0 −1 spec/stubs/templates/includes/base.html.haml
  32. +0 −1 spec/stubs/templates/includes/basic.html.haml
  33. +0 −7 spec/stubs/templates/includes/includes.html.haml
  34. +0 −4 spec/stubs/templates/includes/integration.html.haml
  35. +0 −4 spec/stubs/templates/includes/integration2.html.haml
  36. +0 −1 spec/stubs/templates/index.html.haml
  37. +0 −2 spec/stubs/templates/inheritance/basic/base.html.haml
  38. +0 −2 spec/stubs/templates/inheritance/basic/index.html.haml
  39. +0 −2 spec/stubs/templates/inheritance/capture/haml/base.html.haml
  40. +0 −3 spec/stubs/templates/inheritance/capture/haml/index.html.haml
  41. +0 −3 spec/stubs/templates/library.html.haml
  42. +0 −1 spec/stubs/templates/test.html.haml
  43. +0 −1 spec/stubs/templates/variables.html.haml
  44. +1 −2 stubs/stack/content/Gemfile.rbt
  45. +1 −1 stubs/stack/content/lib/%name%/views.rb.rbt
View
2 lib/rango/mixins/conventional_rendering.rb
@@ -57,7 +57,7 @@ def autorender(context = nil)
def display(object)
autorender
- rescue TemplateNotFound
+ rescue TemplateInheritance::TemplateNotFound
callback = self.formats[request.action]
callback.call
end
View
48 lib/rango/router/adapters/http_router.rb
@@ -0,0 +1,48 @@
+# encoding: utf-8
+
+begin
+ require "http_router"
+rescue LoadError
+ raise LoadError, "You have to install http_router gem!"
+end
+
+Rango::Router.implement(:http_router) do |env|
+ env["rango.router.params"] = env["router.params"] || Hash.new # TODO: nil
+end
+
+module Rango
+ module UrlHelper
+ # url(:login)
+ def url(*args)
+ generator = Rango::Router.app.router.generator
+ route_name = args.shift
+ route = generator.usher.named_routes[route_name]
+ raise "No route found" if route.nil? # TODO: add RouteNotFound to usher and use it here as well
+ if args.empty?
+ generator.generate(route_name) # TODO: usher should probably have path.to_url
+ else
+ alts = route.paths.map(&:dynamic_keys) # one route can have multiple paths as /:id or /:id.:format
+ keys = alts.first
+ # FIXME: take a look at other alts as well !!!!
+ # keys = alts.find.with_index { |item, index| }
+
+ # TODO: optional args
+ keys_generator = keys.each
+ args_generator = args.each
+ opts = Hash.new
+
+ keys.length.times do |index|
+ key = keys_generator.next
+ arg = args_generator.next
+ if arg.respond_to?(key) # post instance
+ opts[key] = arg.send(key)
+ else # it's already a slug
+ opts[key] = arg
+ end
+ end
+
+ generator.generate(route_name, opts)
+ end
+ end
+ end
+end
View
9 lib/rango/template.rb
@@ -0,0 +1,9 @@
+# encoding: utf-8
+
+begin
+ require "template-inheritance"
+rescue LoadError
+ raise LoadError, "You have to install the template-inheritance gem if you want to use templates!"
+end
+
+TemplateInheritance::Template.paths << Rango.root.join("templates").to_s
View
33 lib/rango/templates/exts/haml.rb
@@ -1,33 +0,0 @@
-# encoding: utf-8
-
-# Option default_attributes
-#
-# A hash of default attributes for tags (`{tag => {attribute => default_value}}`).
-# Attributes of each tag will reverse merged with his default attributes, so you
-# don't have to write over and over that script tag has attribute `type` with value
-# `text/javascript`. For example, `%script` compiles to `<script type="text/javascript"></script>`.
-# Defaults to `{script: {type: "text/javascript"}, form: {method: "POST"}}`
-
-module Haml
- module Precompiler
- alias_method :__prerender_tag__, :prerender_tag
- def prerender_tag(name, self_close, attributes)
- # merge given attributes with default attributes from options
- defaults = Tilt::HamlTemplate.options[:default_attributes][name.to_sym]
- attributes = defaults.merge(attributes) if defaults
- __prerender_tag__(name, self_close, attributes)
- end
- end
-
- class Buffer
- alias_method :__open_tag__, :open_tag
- def open_tag(name, self_closing, try_one_line, preserve_tag, escape_html, class_id,
- nuke_outer_whitespace, nuke_inner_whitespace, obj_ref, content, *attributes_hashes)
- defaults = Tilt::HamlTemplate.options[:default_attributes][name.to_sym]
- attributes_hashes.unshift(defaults) if defaults
-
- __open_tag__(name, self_closing, try_one_line, preserve_tag, escape_html, class_id,
- nuke_outer_whitespace, nuke_inner_whitespace, obj_ref, content, *attributes_hashes)
- end
- end
-end
View
29 lib/rango/templates/exts/tilt.rb
@@ -1,29 +0,0 @@
-# encoding: utf-8
-
-require "tilt"
-
-module Rango
- module TiltExtensions
- # Tilt::HamlTemplate.options[:default_attributes] = {script: {type: "text/javascript"}, form: {method: "POST"}}
- module Haml
- def self.included(klass)
- klass.send(:remove_method, :initialize_engine)
- def klass.options
- @options ||= Hash.new
- end
- end
-
- def initialize_engine
- require_template_library 'haml' unless defined? ::Haml::Engine
- require "rango/templates/exts/haml" if self.class.options[:default_attributes]
- end
-
- def initialize(*args)
- super
- self.options.merge!(self.class.options)
- end
- end
- end
-end
-
-Tilt::HamlTemplate.send(:include, Rango::TiltExtensions::Haml)
View
147 lib/rango/templates/helpers.rb
@@ -1,147 +0,0 @@
-# encoding: utf-8
-
-require "rango"
-require "rango/templates/template"
-
-module Rango
- SubtemplateNotFound = Class.new(StandardError)
-
- module TemplateHelpers
- def self.extended(scope)
- class << scope
- attr_accessor :template
- attr_accessor :context
- # @example Capture being used in a .html.erb page:
- # <% @foo = capture do %>
- # <p>Some Foo content!</p>
- # <% end %>
- #
- # @params [*args] Arguments to pass to the block.
- # @params [&block] The template block to call.
- # @return [String] The output of the block.
- # @api private
- def capture(*args, &block)
- capture_method = "capture_#{self.template.adapter}"
- if self.respond_to?(capture_method) # tilt doesn't support @_out_buf for haml
- self.send("capture_#{self.template.adapter}", *args, &block)
- else
- # @_out_buf comes from tilt
- unless self.instance_variable_defined?("@_out_buf")
- raise "Adapter #{self.template.adapter} doesn't support capturing"
- end
- _old_buf, @_out_buf = @_out_buf, ""
- block.call(*args)
- @_out_buf = _old_buf.chomp.strip
- end
- end
-
- def concat(string)
- concat_method = "concat_#{self.template.adapter}"
- if self.respond_to?(concat_method) # tilt doesn't support @_out_buf for haml
- self.send("concat_#{self.template.adapter}", string)
- else
- # @_out_buf comes from tilt
- unless self.instance_variable_defined?("@_out_buf")
- raise "Adapter #{self.template.adapter} doesn't support concating"
- end
- @_out_buf << string
- end
- end
- end
- end
-
- def self.included(scope_class)
- scope_class.class_eval { attr_accessor :template }
- end
-
- # post/show.html: it's block is the block we like to see in output
- # post/base.html
- # base.html: here it will be rendered, so we need block to returns the correct block code
- # @since 0.0.2
- # @version 0.2
- def block(name, value = nil, &block)
- raise ArgumentError, "Block has to have a name!" if name.nil?
- raise ArgumentError, "You have to provide value or block, not both of them!" if value && block
- self.template.blocks[name] ||= block ? self.template.scope.capture(&block) : value
- return self.template.blocks[name]
- end
-
- # - extend_block(:head) do
- # = pupu :lighter, syntax: "html", theme: "standard"
- # = block(:head)
- def extend_block(name, value = nil, &block)
- unless self.template.blocks[name]
- raise NameError, "Block #{name.inspect} wasn't defined yet, you can't extend it!"
- end
- self.enhance_block(name, value, &block)
- end
-
- def enhance_block(name, value = nil, &block)
- raise ArgumentError, "Block has to have a name!" if name.nil?
- raise ArgumentError, "You have to provide value or block, not both of them!" if value && block
- value = self.template.scope.capture(&block) if value.nil? && block
- self.template.blocks[name] = value if value
- return self.template.blocks[name]
- end
-
- # Clears default content of given block.
- #
- # @example
- # clear_block(:flyout)
- def clear_block(name)
- raise ArgumentError, "You need to specify name of block to clear." if name.nil?
- self.template.blocks[name] = String.new
- end
-
- # Low-level rendering method for templates.
- #
- # @since 0.2
- # @example
- # render "base.html"
- # render "./base.html"
- # render "../base.html"
- def render(path, context = Hash.new)
- full_path = normalize_template_path(path)
- original_template = self.template
- template = Rango::Template.new(full_path, self) # self is scope
- self.template = original_template
- return template.render(context)
- rescue Exceptions::TemplateNotFound # FIXME: this doesn't work
- raise SubtemplateNotFound, "Template #{path} doesn't exist in #{full_path}"
- end
-
- # partial "products/list"
- # @since 0.0.2
- # @version 0.2.1
- def partial(template, extra_context = Hash.new)
- # NOTE: we can't use File.split because it normalize the path,
- # so "./base.html" will be the same as "base.html", but it shouldn't be
- *path, basename = template.split("/")
- render File.join(path.join("/"), "_#{basename}"), self.template.context.merge(extra_context)
- end
-
- # @since 0.2
- def includes(template, context = Hash.new)
- render normalize_template_path(template), context
- return true
- end
-
- # extends "base.html"
- # @since 0.0.2
- def extends(path)
- # we can't just create a new template, because it has to do it after it reads the whole file
- self.template.supertemplate = normalize_template_path(path)
- end
-
- # @since 0.2
- def normalize_template_path(template)
- if template.start_with?("./")
- File.expand_path(File.join(File.dirname(self.template.fullpath), template))
- elsif template.start_with?("../")
- File.expand_path(File.join(File.dirname(self.template.fullpath), "..", template))
- else
- template
- end
- end
- end
-end
View
87 lib/rango/templates/template.rb
@@ -1,87 +0,0 @@
-# encoding: utf-8
-
-require "rango/templates/exts/tilt"
-require "rango/core_ext" # String#snake_case
-require "rango/templates/helpers"
-require "rango/exceptions"
-
-module Rango
- module Exceptions # so we can catch it with other HTTP errors
- TemplateNotFound = Class.new(NotFound) { self.name = "Template Not Found" }
- end
-
- class Template
- def self.template_paths
- @@template_paths ||= [Rango.root.join("templates").to_s]
- end
-
- # template -> supertemplate is the same relationship as class -> superclass
- # @since 0.0.2
- attr_accessor :path, :scope, :supertemplate, :context
-
- # @since 0.0.2
- attr_writer :blocks
- def blocks
- @blocks ||= Hash.new
- end
-
- # @since 0.0.2
- def initialize(path, scope = Object.new)
- self.path = path#[scope.class.template_prefix.chomp("/"), template].join("/")
- self.scope = scope
- self.scope.extend(TemplateHelpers)
- # this enables template caching
- unless Rango.development?
- self.scope.extend(Tilt::CompileSite)
- end
- self.scope.template = self
- end
-
- # @since 0.0.2
- def fullpath
- @fullpath ||= begin
- if self.path.match(/^(\/|\.)/) # /foo or ./foo
- Dir[self.path, "#{self.path}.*"].find {|file| !File.directory?(file)}
- else
- self.find_in_template_paths
- end
- end
- end
-
- def adapter
- self.template.class.name.split("::").last.snake_case.sub("_template", "")
- end
-
- def extension # haml, erb ...
- File.extname(path)[1..-1]
- end
-
- def template(options = Hash.new)
- @template ||= Tilt.new(self.fullpath, nil, options)
- end
-
- # @since 0.0.2
- def render(context = Hash.new)
- raise Exceptions::TemplateNotFound.new("Template #{self.path} wasn't found in these template_paths: #{self.class.template_paths.inspect}") if self.fullpath.nil?
- Rango.logger.info("Rendering template #{self.path} with context keys #{context.keys.inspect}")
- self.scope.context = self.context = context # so we can access context in the scope object as well
- value = self.template.render(self.scope, context)
- Rango.logger.debug("Available blocks: #{self.blocks.keys.inspect}")
- if self.supertemplate
- Rango.logger.debug("Extends call: #{self.supertemplate}")
- supertemplate = self.class.new(self.supertemplate, self.scope)
- supertemplate.blocks = self.blocks
- return supertemplate.render(context)
- end
- value
- end
-
- protected
- def find_in_template_paths
- self.class.template_paths.each do |directory|
- path = File.join(directory, self.path)
- return Dir[path, "#{path}.*"].find {|file| !File.directory?(file)}
- end
- end
- end
-end
View
2 lib/rango/version.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
module Rango
- VERSION = "0.3"
+ VERSION = "0.2.5.1"
end
View
4 spec/rango/mixins/render_spec.rb
@@ -41,8 +41,8 @@
body.should match(/Hi\!/)
end
- it "should raise TemplateNotFound if template wasn't found" do
- -> { render "idonotexist.html" }.should raise_error(Rango::Exceptions::TemplateNotFound)
+ it "should raise TemplateInheritance::TemplateNotFound if template wasn't found" do
+ -> { render "idonotexist.html" }.should raise_error(TemplateInheritance::TemplateNotFound)
end
end
end
View
0 spec/rango/templates/exts/haml_spec.rb
No changes.
View
0 spec/rango/templates/exts/tilt_spec.rb
No changes.
View
139 spec/rango/templates/helpers_spec.rb
@@ -1,139 +0,0 @@
-# encoding: utf-8
-
-require_relative "../../spec_helper"
-require "rango/templates/helpers"
-
-Rango::Template.template_paths.clear.push(File.join(STUBS_ROOT, "templates"))
-
-describe Rango::TemplateHelpers do
- include Rango::TemplateHelpers
- describe "#partial" do
- it "should work" do
- pending "This can't work because self.template doesn't exist, we have to use render mixin"
- partial "basic.html"
- end
-
- it "should share context with the parent template" do
- pending
- end
-
- it "should be able to specify additional context which isn't propagated to the parent template" do
- pending
- end
- end
-
- describe "#render" do
- it "should consider 'path.html' as a path relative to Template.template_paths" do
- pending
- end
-
- it "should consider './path.html' as a path relative to the current template" do
- pending
- end
-
- it "should look for '../path.html' in the parent directory of directory with current template" do
- pending
- end
- end
-
- describe "#includes" do
- require "rango/mixins/render"
- it "should return true" do
- Rango::RenderMixin.render("includes/basic.html").strip.should eql("true")
- end
-
- it "should work with blocks" do
- Rango::RenderMixin.render("includes/includes.html")
- end
-
- it "should work with extends" do
- output = Rango::RenderMixin.render("includes/integration.html")
- output.strip.should eql("Greeting by Jakub Stastny")
- end
-
- it "should work with extends" do
- output = Rango::RenderMixin.render("includes/integration2.html")
- output.strip.should eql("Greeting by Jakub Stastny")
- end
- end
-
- describe "extends" do
- end
-
- describe "block" do
- it "should raise argument error if name isn't specified" do
- -> { block(nil) }.should raise_error(ArgumentError)
- end
-
- it "should work as a setter if a value is provided" do
- output = Rango::RenderMixin.render("block/value.html")
- output.strip.should eql("a value")
- end
-
- it "should work as a setter if a block is provided" do
- output = Rango::RenderMixin.render("block/block.html")
- output.strip.should eql("a block")
- end
-
- it "should work as a getter" do
- output = Rango::RenderMixin.render("block/getter.html")
- output.strip.should eql("Hello World!")
- end
-
- it "should raise argument error if both value and block is provided" do
- -> { Rango::RenderMixin.render("block/error.html") }.should raise_error(ArgumentError)
- end
-
- it "should store the first non-nil value" do
- output = Rango::RenderMixin.render("block/blocks.html")
- output.strip.should eql("first")
- end
- end
-
- describe "extend_block" do
- it "should raise argument error if name isn't specified" do
- -> { Rango::RenderMixin.render("extend_block/name_error.html") }.should raise_error(NameError)
- end
-
- it "should raise argument error if both value and block is provided" do
- -> { Rango::RenderMixin.render("extend_block/error.html") }.should raise_error(ArgumentError)
- end
-
- it "should raise argument error if block of given name doesn't exist so far" do
- -> { Rango::RenderMixin.render("extend_block/error2.html") }.should raise_error
- end
-
- it "should work with super()-like inheritance" do
- Rango::RenderMixin.render("extend_block/basic.html")
- end
-
- it "should do nothing if the value or block is nil" do
- output = Rango::RenderMixin.render("extend_block/nil.html")
- output.strip.should eql("Original")
- end
- end
-
- describe "enhance_block" do
- it "should work even if the block isn't defined so far" do
- output = Rango::RenderMixin.render("enhance_block/standalone.html")
- output.strip.should eql("Hello World!")
- end
-
- it "should not raise argument error if name isn't specified" do
- -> { Rango::RenderMixin.render("enhance_block/name_error.html") }.should_not raise_error(NameError)
- end
-
- it "should raise argument error if both value and block is provided" do
- -> { Rango::RenderMixin.render("enhance_block/error.html") }.should raise_error(ArgumentError)
- end
-
- it "should work with super()-like inheritance" do
- Rango::RenderMixin.render("enhance_block/basic.html")
- end
-
- it "should do nothing if the value or block is nil" do
- output = Rango::RenderMixin.render("enhance_block/nil.html")
- output.strip.should eql("Original")
- end
- end
-end
View
61 spec/rango/templates/template_spec.rb
@@ -1,61 +0,0 @@
-# encoding: utf-8
-
-require_relative "../../spec_helper"
-require "rango/templates/template"
-
-Rango::Template.template_paths.clear.push(File.join(STUBS_ROOT, "templates"))
-
-describe Rango::Template do
- describe "#initialize" do
- it "should take path as a first argument" do
- template = Rango::Template.new("test.html")
- template.path.should eql("test.html")
- end
-
- it "should take scope as an optional second argument" do
- scope = Object.new
- template = Rango::Template.new("test.html", scope)
- template.scope.should eql(scope)
- end
- end
-
- describe "#fullpath" do
- it "should find" do
- template = Rango::Template.new("test.html")
- fullpath = File.join(STUBS_ROOT, "templates", "test.html.haml")
- template.fullpath.should eql(fullpath)
- end
- end
-
- describe "#render" do
- it "should raise TemplateNotFound if template can't be found" do
- template = Rango::Template.new("idonotexist.html")
- -> { template.render }.should raise_error(Rango::Exceptions::TemplateNotFound)
- end
-
- it "should render" do
- template = Rango::Template.new("test.html")
- template.render.should eql("<html></html>\n")
- end
-
- it "should have template inheritance" do
- template = Rango::Template.new("inheritance/basic/index.html")
- end
-
- it "should capture haml" do
- template = Rango::Template.new("inheritance/capture/haml/index.html")
- template.render
- template.blocks[:content].should match("Hello!")
- end
- end
-
- describe "variables" do
- before(:each) do
- @template = Rango::Template.new("variables.html")
- end
-
- it "should capture erb" do
- # @template.render(title: "Hi!").should match("Hi!")
- end
- end
-end
View
13 spec/rango_spec.rb
@@ -5,14 +5,15 @@
describe Rango do
- it "should has logger" do
- #Rango.logger.should respond_to?(:debug)
- #Rango.logger.should respond_to?(:info)
- #Rango.logger.should respond_to?(:warn)
- #Rango.logger.should respond_to?(:error)
- #Rango.logger.should respond_to?(:fatal)
+ it "should have logger" do
+ Rango.logger.should respond_to?(:debug)
+ Rango.logger.should respond_to?(:info)
+ Rango.logger.should respond_to?(:warn)
+ Rango.logger.should respond_to?(:error)
+ Rango.logger.should respond_to?(:fatal)
end
+ # what about logger vs. extlib logger (fatal!)
describe ".boot" do
# TODO
end
View
2 spec/stubs/templates/block/block.html.haml
@@ -1,2 +0,0 @@
-= block(:second) do
- a block
View
5 spec/stubs/templates/block/blocks.html.haml
@@ -1,5 +0,0 @@
-- block(:head, nil)
-- block(:head, "first")
-- block(:head, "second")
-
-= block(:head)
View
2 spec/stubs/templates/block/error.html.haml
@@ -1,2 +0,0 @@
-= block(:content, "value") do
- Content from block
View
3 spec/stubs/templates/block/getter.html.haml
@@ -1,3 +0,0 @@
-- block(:content, "Hello World!")
-
-= block(:content)
View
1 spec/stubs/templates/block/value.html.haml
@@ -1 +0,0 @@
-= block(:one, "a value")
View
1 spec/stubs/templates/context_id.html.haml
@@ -1 +0,0 @@
-= self.object_id
View
5 spec/stubs/templates/enhance_block/basic.html.haml
@@ -1,5 +0,0 @@
-- block(:content) do
- Original
-
-= enhance_block(:content) do
- I own the only #{block(:content)}!
View
3 spec/stubs/templates/enhance_block/error.html.haml
@@ -1,3 +0,0 @@
-= enhance_block(:content, "another value") do
- Content from block
-
View
1 spec/stubs/templates/enhance_block/name_error.html.haml
@@ -1 +0,0 @@
-- enhance_block(nil)
View
3 spec/stubs/templates/enhance_block/nil.html.haml
@@ -1,3 +0,0 @@
-- block(:content, "Original")
-
-= enhance_block(:content, nil)
View
2 spec/stubs/templates/enhance_block/standalone.html.haml
@@ -1,2 +0,0 @@
-= enhance_block(:content) do
- Hello World!
View
5 spec/stubs/templates/extend_block/basic.html.haml
@@ -1,5 +0,0 @@
-- block(:content) do
- Original
-
-= extend_block(:content) do
- I own the only #{block(:content)}!
View
5 spec/stubs/templates/extend_block/error.html.haml
@@ -1,5 +0,0 @@
-- block(:content, "value")
-
-= extend_block(:content, "another value") do
- Content from block
-
View
1 spec/stubs/templates/extend_block/error2.html.haml
@@ -1 +0,0 @@
-= extend_block(:content, "foo")
View
1 spec/stubs/templates/extend_block/name_error.html.haml
@@ -1 +0,0 @@
-- extend_block(nil)
View
4 spec/stubs/templates/extend_block/nil.html.haml
@@ -1,4 +0,0 @@
-- block(:content) do
- Original
-
-= extend_block(:content, nil)
View
1 spec/stubs/templates/includes/base.html.haml
@@ -1 +0,0 @@
-== #{block(:title)} by #{block(:author)}
View
1 spec/stubs/templates/includes/basic.html.haml
@@ -1 +0,0 @@
-= includes "library.html"
View
7 spec/stubs/templates/includes/includes.html.haml
@@ -1,7 +0,0 @@
-- includes "library.html"
-
-%html
- %head
- %title= block(:title)
-
- %body= block(:content)
View
4 spec/stubs/templates/includes/integration.html.haml
@@ -1,4 +0,0 @@
-- includes "library.html"
-- extends "includes/base.html"
-
-= block(:author, "Jakub Stastny")
View
4 spec/stubs/templates/includes/integration2.html.haml
@@ -1,4 +0,0 @@
-- extends "includes/base.html"
-- includes "library.html"
-
-= block(:author, "Jakub Stastny")
View
1 spec/stubs/templates/index.html.haml
@@ -1 +0,0 @@
-= title
View
2 spec/stubs/templates/inheritance/basic/base.html.haml
@@ -1,2 +0,0 @@
-%html
- %body= block(:content)
View
2 spec/stubs/templates/inheritance/basic/index.html.haml
@@ -1,2 +0,0 @@
-- extends "inheritance/basic/base.html"
-- block(:content, "Hello!")
View
2 spec/stubs/templates/inheritance/capture/haml/base.html.haml
@@ -1,2 +0,0 @@
-%html
- %body= block(:content)
View
3 spec/stubs/templates/inheritance/capture/haml/index.html.haml
@@ -1,3 +0,0 @@
-- extends "inheritance/capture/haml/base.html"
-- block(:content) do
- Hello!
View
3 spec/stubs/templates/library.html.haml
@@ -1,3 +0,0 @@
-- block(:title, "Greeting") # we don't want to show this in the partial
-- block(:content) do
- Hello World!
View
1 spec/stubs/templates/test.html.haml
@@ -1 +0,0 @@
-%html
View
1 spec/stubs/templates/variables.html.haml
@@ -1 +0,0 @@
-= title
View
3 stubs/stack/content/Gemfile.rbt
@@ -40,8 +40,7 @@ gem "rack-mount"#, git: "git://github.com/josh/rack-mount.git"
gem "rack-router"#, git: "git://github.com/carllerche/rack-router.git"
<% end %>
-gem "tilt"#, git: "git://github.com/rtomayko/tilt.git"
-gem "haml"#, git: "git://github.com/nex3/haml.git"
+gem "template-inheritance"#, git: "git://github.com/botanicus/template-inheritance.git"
gem "helpers"#, git: "git://github.com/botanicus/helpers.git"
gem "formidable"#, git: "git://github.com/botanicus/formidable.git"
gem "pupu"#, git: "git://github.com/botanicus/pupu.git"
View
2 stubs/stack/content/lib/%name%/views.rb.rbt
@@ -24,7 +24,7 @@ module <%= @name.camel_case %>
def render_http_error_template(exception)
render "errors/#{exception.status}.html"
- rescue TemplateNotFound
+ rescue TemplateInheritance::TemplateNotFound
render "errors/500.html"
end
end

0 comments on commit 376fad8

Please sign in to comment.
Something went wrong with that request. Please try again.