Allow frontmatter renderer_options key to overwrite renderer options on a per-file basis. closes #859
This commit is contained in:
parent
9fc06035b1
commit
a0445e405a
11 changed files with 82 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
master
|
master
|
||||||
===
|
===
|
||||||
|
|
||||||
|
* Allow frontmatter "renderer_options" key to overwrite renderer options on a per-file basis. #859
|
||||||
* Added a "t" helper that delegates to I18n.t, just like Rails. #853.
|
* Added a "t" helper that delegates to I18n.t, just like Rails. #853.
|
||||||
* I18n will fall back to the default locale if a translation in the current locale is not found. You can disable this behavior by passing `:no_fallbacks => true` when activating `:i18n`. More settings documented at https://github.com/svenfuchs/i18n/wiki/Fallbacks . #853
|
* I18n will fall back to the default locale if a translation in the current locale is not found. You can disable this behavior by passing `:no_fallbacks => true` when activating `:i18n`. More settings documented at https://github.com/svenfuchs/i18n/wiki/Fallbacks . #853
|
||||||
* Switched default Markdown engine to Kramdown. #852
|
* Switched default Markdown engine to Kramdown. #852
|
||||||
|
|
|
@ -250,6 +250,9 @@ module Middleman
|
||||||
options = opts.merge(options_for_ext(extension))
|
options = opts.merge(options_for_ext(extension))
|
||||||
options[:outvar] ||= '@_out_buf'
|
options[:outvar] ||= '@_out_buf'
|
||||||
|
|
||||||
|
# Overwrite with frontmatter options
|
||||||
|
options = options.deep_merge(options[:renderer_options]) if options[:renderer_options]
|
||||||
|
|
||||||
template_class = Tilt[path]
|
template_class = Tilt[path]
|
||||||
# Allow hooks to manipulate the template before render
|
# Allow hooks to manipulate the template before render
|
||||||
self.class.callbacks_for_hook(:before_render).each do |callback|
|
self.class.callbacks_for_hook(:before_render).each do |callback|
|
||||||
|
|
|
@ -117,6 +117,15 @@ module Middleman
|
||||||
instrument "render.resource", :path => relative_source do
|
instrument "render.resource", :path => relative_source do
|
||||||
md = metadata.dup
|
md = metadata.dup
|
||||||
opts = md[:options].deep_merge(opts)
|
opts = md[:options].deep_merge(opts)
|
||||||
|
|
||||||
|
# Pass "renderer_options" hash from frontmatter along to renderer
|
||||||
|
if md[:page]["renderer_options"]
|
||||||
|
opts[:renderer_options] = {}
|
||||||
|
md[:page]["renderer_options"].each do |k, v|
|
||||||
|
opts[:renderer_options][k.to_sym] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
locs = md[:locals].deep_merge(locs)
|
locs = md[:locals].deep_merge(locs)
|
||||||
|
|
||||||
# Forward remaining data to helpers
|
# Forward remaining data to helpers
|
||||||
|
|
|
@ -42,6 +42,27 @@ Feature: Markdown support
|
||||||
When I go to "/hard_wrap.html"
|
When I go to "/hard_wrap.html"
|
||||||
Then I should see "br"
|
Then I should see "br"
|
||||||
|
|
||||||
|
Scenario: Redcarpet per-page frontmatter options
|
||||||
|
Given a fixture app "markdown-frontmatter-options-app"
|
||||||
|
And a file named "config.rb" with:
|
||||||
|
"""
|
||||||
|
set :markdown_engine, :redcarpet
|
||||||
|
set :markdown, :smartypants => true
|
||||||
|
"""
|
||||||
|
Given the Server is running at "markdown-frontmatter-options-app"
|
||||||
|
When I go to "/smarty_pants-default.html"
|
||||||
|
Then I should see "“"
|
||||||
|
When I go to "/smarty_pants-on.html"
|
||||||
|
Then I should see "“"
|
||||||
|
When I go to "/smarty_pants-off.html"
|
||||||
|
Then I should not see "“"
|
||||||
|
When I go to "/tables-default.html"
|
||||||
|
Then I should not see "<table>"
|
||||||
|
When I go to "/tables-on.html"
|
||||||
|
Then I should see "<table>"
|
||||||
|
When I go to "/tables-off.html"
|
||||||
|
Then I should not see "<table>"
|
||||||
|
|
||||||
Scenario: Redcarpet uses our link_to and image_tag helpers
|
Scenario: Redcarpet uses our link_to and image_tag helpers
|
||||||
Given a fixture app "markdown-app"
|
Given a fixture app "markdown-app"
|
||||||
And a file named "config.rb" with:
|
And a file named "config.rb" with:
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
set :markdown, :smartypants => true
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
layout: false
|
||||||
|
---
|
||||||
|
|
||||||
|
"Hello"
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
layout: false
|
||||||
|
renderer_options:
|
||||||
|
smartypants: false
|
||||||
|
---
|
||||||
|
|
||||||
|
"Hello"
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
layout: false
|
||||||
|
renderer_options:
|
||||||
|
smartypants: true
|
||||||
|
---
|
||||||
|
|
||||||
|
"Hello"
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
layout: false
|
||||||
|
---
|
||||||
|
|
||||||
|
First Header | Second Header
|
||||||
|
------------- | -------------
|
||||||
|
Content Cell | Content Cell
|
||||||
|
Content Cell | Content Cell
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
layout: false
|
||||||
|
renderer_options:
|
||||||
|
tables: false
|
||||||
|
---
|
||||||
|
|
||||||
|
First Header | Second Header
|
||||||
|
------------- | -------------
|
||||||
|
Content Cell | Content Cell
|
||||||
|
Content Cell | Content Cell
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
layout: false
|
||||||
|
renderer_options:
|
||||||
|
tables: true
|
||||||
|
---
|
||||||
|
|
||||||
|
First Header | Second Header
|
||||||
|
------------- | -------------
|
||||||
|
Content Cell | Content Cell
|
||||||
|
Content Cell | Content Cell
|
Loading…
Reference in a new issue