Allow for overriding only specific Mustache templates/partials. (#1719)
* Allow for overriding only specific templates/partials. Resolves #1450.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<nav>
|
||||
<div style="background-color: red;">NAVBAR_OVERRIDE</div>
|
||||
|
||||
<p>Still include an original partial to ensure the fallback works even when nested from an overriden partial:</p>
|
||||
<div>
|
||||
{{>mobilenav}}
|
||||
</div>
|
||||
</nav>
|
||||
@@ -0,0 +1,12 @@
|
||||
<div id="wiki-wrapper" class="page">
|
||||
|
||||
<p>Include an overridden partial:</p>
|
||||
<div id="head">
|
||||
{{#navbar?}}{{>navbar}}{{/navbar?}}
|
||||
</div>
|
||||
|
||||
<div style="background-color: red;">PAGE_OVERRIDE</div>
|
||||
|
||||
{{>wiki_content}}
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,43 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
|
||||
class TestTemplateCascade < Minitest::Unit::TestCase
|
||||
include Rack::Test::Methods
|
||||
|
||||
def setup
|
||||
@path = cloned_testpath('examples/lotr.git')
|
||||
Precious::App.set(:gollum_path, @path)
|
||||
Precious::App.set(:wiki_options, {template_dir: testpath('examples/template_cascade')})
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
end
|
||||
|
||||
def teardown
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
|
||||
def app
|
||||
Precious::App
|
||||
end
|
||||
|
||||
def test_overridden_page_template_is_used
|
||||
get '/Home'
|
||||
|
||||
assert last_response.body.include?('PAGE_OVERRIDE')
|
||||
end
|
||||
|
||||
def test_overridden_navbar_partial_is_used
|
||||
get '/Home'
|
||||
|
||||
assert last_response.body.include?('NAVBAR_OVERRIDE')
|
||||
end
|
||||
|
||||
def test_overridden_templates_are_ignore_without_template_dir_set
|
||||
Precious::App.set(:wiki_options, {template_dir: nil})
|
||||
|
||||
get '/Home'
|
||||
assert_equal '/Home', last_request.fullpath
|
||||
assert last_response.ok?
|
||||
assert_no_match /PAGE_OVERRIDE/, last_response.body
|
||||
assert_no_match /NAVBAR_OVERRIDE/, last_response.body
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user