From c1743256b4a8773eec774f3e3cf00a7c7352a9b3 Mon Sep 17 00:00:00 2001 From: Vasiliy Yakliushin Date: Sun, 28 Apr 2019 20:09:32 +0200 Subject: [PATCH 1/2] Add pandoc support Here I try to fix an another warning from tests. ``` cannot load such file -- pandoc-ruby: skipping markdown tests with Tilt::PandocTemplate ``` `pandoc-ruby` is not defined in Gemfile, so I add it there. This gem has a prerequisite dependency `pandoc` application that can be installed via homebrew. That's why I update travis.yml to make it available during a test run. The final step to make it work is to exclude `outvar` from the option's list provided to the template. When `pandoc` application is called with unsupported parameters it stops the execution and returns an error. --- .travis.yml | 2 +- Gemfile | 1 + README.md | 2 ++ lib/sinatra/base.rb | 4 +++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e3b10e6d9..c1ea9a7ce7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ addons: - ubuntu-toolchain-r-test packages: - g++-4.8 - + - pandoc rvm: - 2.2.10 - 2.3.8 diff --git a/Gemfile b/Gemfile index 6df880fd4f..7bee5fab36 100644 --- a/Gemfile +++ b/Gemfile @@ -60,6 +60,7 @@ if RUBY_ENGINE == "ruby" gem 'reel-rack' gem 'celluloid', '~> 0.16.0' gem 'commonmarker', '~> 0.20.0' + gem 'pandoc-ruby', '~> 2.0.2' gem 'simplecov', require: false end diff --git a/README.md b/README.md index 336ac2b994..effb719297 100644 --- a/README.md +++ b/README.md @@ -750,6 +750,8 @@ template, you almost always want to pass locals to it. BlueCloth, kramdown, maruku + commonmarker + pandoc diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index a02fdf0e78..9d2fa946ae 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -722,6 +722,7 @@ def liquid(template, options = {}, locals = {}, &block) end def markdown(template, options = {}, locals = {}) + options[:default_outvar] = false render :markdown, template, options, locals end @@ -818,10 +819,11 @@ def render(engine, data, options = {}, locals = {}, &block) content_type = options.delete(:content_type) || content_type layout_engine = options.delete(:layout_engine) || engine scope = options.delete(:scope) || self + default_outvar = options.delete(:default_outvar) != false options.delete(:layout) # set some defaults - options[:outvar] ||= '@_out_buf' + options[:outvar] ||= '@_out_buf' if default_outvar options[:default_encoding] ||= settings.default_encoding # compile and render template From 6ebf9ceb27beaaaa85fb85f3aef3607d3221c2cd Mon Sep 17 00:00:00 2001 From: Vasiliy Yakliushin Date: Tue, 25 Jun 2019 21:31:15 +0200 Subject: [PATCH 2/2] Rename `default_outvar` to `exclude_outvar` --- lib/sinatra/base.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 9d2fa946ae..dc538a634a 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -722,7 +722,7 @@ def liquid(template, options = {}, locals = {}, &block) end def markdown(template, options = {}, locals = {}) - options[:default_outvar] = false + options[:exclude_outvar] = true render :markdown, template, options, locals end @@ -819,11 +819,11 @@ def render(engine, data, options = {}, locals = {}, &block) content_type = options.delete(:content_type) || content_type layout_engine = options.delete(:layout_engine) || engine scope = options.delete(:scope) || self - default_outvar = options.delete(:default_outvar) != false + exclude_outvar = options.delete(:exclude_outvar) options.delete(:layout) # set some defaults - options[:outvar] ||= '@_out_buf' if default_outvar + options[:outvar] ||= '@_out_buf' unless exclude_outvar options[:default_encoding] ||= settings.default_encoding # compile and render template