diff -Nru ruby-tilt-2.0.1/bin/tilt ruby-tilt-2.0.8/bin/tilt --- ruby-tilt-2.0.1/bin/tilt 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/bin/tilt 2017-08-18 22:03:01.000000000 +0000 @@ -10,14 +10,15 @@ to determine the template's type. Options - -l, --list List template engines + file patterns and exit - -t, --type= Use this template engine; required if no - -y, --layout= Use as a layout template + -l, --list List template engines + file patterns and exit + -t, --type= Use this template engine; required if no + -y, --layout= Use as a layout template + + -D= Define variable as + -d, --define-file= Load YAML from and use for variables + --vars= Evaluate to Hash and use for variables - -D= Define variable as - --vars= Evaluate to Hash and use for variables - - -h, --help Show this help message + -h, --help Show this help message Convert markdown to HTML: $ tilt foo.markdown > foo.html @@ -77,6 +78,15 @@ locals[key.to_sym] = value end + # define local variables from YAML or JSON + o.on("-d", "--define-file=FILE", String) do |file| + require 'yaml' + abort "no such define file: #{file}" unless File.exist? file + hash = File.open(file, 'r:bom|utf-8') { |f| YAML.load f, file } + abort "vars must be a Hash, not #{hash.inspect}" if !hash.is_a?(Hash) + hash.each { |key, value| locals[key.to_sym] = value } + end + # define local variables using a Ruby hash o.on("--vars=RUBY") do |ruby| hash = eval(ruby) diff -Nru ruby-tilt-2.0.1/CHANGELOG.md ruby-tilt-2.0.8/CHANGELOG.md --- ruby-tilt-2.0.1/CHANGELOG.md 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/CHANGELOG.md 2017-08-18 22:03:01.000000000 +0000 @@ -1,5 +1,61 @@ ## master +## 2.0.8 (2017-07-24) + +* Register .tsx for TypeScript (#315, backus) +* Use Haml 5's new API (#312, k0kubun) +* Use correct parser options for CommonMarker (#320, rewritten) +* Suppress warnings when no locals are used (#304, amatsuda) +* Haml: Accept `outvar` (#317, k0kubun) + +## 2.0.7 (2017-03-19) + +* Do not modify BasicObject during template compilation on ruby 2.0+ (#309, jeremyevans) + +## 2.0.6 (2017-01-26) + +* Add support for LiveScript (#286, @Announcement Jacob Francis Powers) +* Add support for Sigil (#302, winebarrel) +* Add support for Erubi (#308, jeremyevans) +* Add support for options in Liquid (#298, #299, laCour) +* Always sort locals by strings (#307, jeremyevans) + +* Fix test warnings (#305, amatsuda) +* Fix indentation (#293, yui-knk) +* Use SVG badges in README (#294, vasinov) +* Fix typo and trailing space (#295, #296, karloescota) + +## 2.0.5 (2016-06-02) + +* Add support for reST using Pandoc (#284, mfenner) +* Make lazy loading thread-safe; remove warning (judofyr) + +## 2.0.4 (2016-05-16) + +* Fix regression in BuilderTemplate (#283, judofyr) + +## 2.0.3 (2016-05-12) + +* Add Pandoc support (#276, jmuheim) +* Add CommonMark support (#282, raphink) +* Add TypeScript support (#278, nghitran) +* Work with frozen string literal (#274, jeremyevans) +* Add MIME type for Babel (#273, SaitoWu) + +## 2.0.2 (2016-01-06) + +* Pass options to Redcarpet (#250, hughbien) +* Haml: Improve error message on frozen self (judofyr) +* Add basic support for Babel (judofyr) +* Add support for .litcoffee (#243, judofyr, mr-vinn) +* Document Tilt::Cache (#266, tommay) +* Sort local keys for better caching (#257, jeremyevans) +* Add more CSV options (#256, Juanmcuello) +* Add Prawn template (kematzy) +* Improve cache-miss performance in Tilt::Cache (#251, tommay) +* Add man page (#241, josephholsten) +* Support YAML/JSON data in bin/tilt (#241, josephholsten) + ## 2.0.1 (2014-03-21) * Fix Tilt::Mapping bug in Ruby 2.1.0 (9589652c569760298f2647f7a0f9ed4f85129f20) @@ -69,4 +125,3 @@ * Support RDoc 3.10 (#112, timfel) * Always compile templates; remove old source evaluator (rtomayko) * Less: Options are now being passed to the parser (#106, cowboyd) - Binary files /tmp/tmptz9duD/4U4Z19rmDG/ruby-tilt-2.0.1/checksums.yaml.gz and /tmp/tmptz9duD/RwYkX2rpmH/ruby-tilt-2.0.8/checksums.yaml.gz differ diff -Nru ruby-tilt-2.0.1/COPYING ruby-tilt-2.0.8/COPYING --- ruby-tilt-2.0.1/COPYING 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/COPYING 2017-08-18 22:03:01.000000000 +0000 @@ -1,4 +1,4 @@ -Copyright (c) 2010 Ryan Tomayko +Copyright (c) 2010-2016 Ryan Tomayko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to diff -Nru ruby-tilt-2.0.1/debian/changelog ruby-tilt-2.0.8/debian/changelog --- ruby-tilt-2.0.1/debian/changelog 2016-01-13 07:45:24.000000000 +0000 +++ ruby-tilt-2.0.8/debian/changelog 2018-04-11 01:22:35.000000000 +0000 @@ -1,3 +1,32 @@ +ruby-tilt (2.0.8-1) unstable; urgency=low + + * Team upload + + [ Cédric Boutillier ] + * Bump debhelper compatibility level to 9 + * Remove version in the gem2deb build-dependency + * Use https:// in Vcs-* fields + * Use https:// in Vcs-* fields + * Bump Standards-Version to 3.9.7 (no changes needed) + * Run wrap-and-sort on packaging files + + [ Joseph Herlant ] + * d/control: update Vcs-* to point to salsa directly + * d/control, d/compat: upgrade standards to 4.1.4 and compat to 11 + * d/copyright: fix file-contains-trailing-whitespace + * d/control: fix homepage-field-uses-insecure-uri + * d/copyright: fix insecure-copyright-format-uri + * d/watch: fix debian-watch-uses-insecure-uri + * d/p/force_encoding_erb_test: fix spelling-error-in-patch-description + * d/control: enable autopkgtest + * New upstream version 2.0.8 + * Remove haml version patch that is no longer necessary + * Update existing patches to fit the new version + * d/copyright: update copyright years to reflect upstream change + * d/rules: add GEM2DEB_TEST_RUNNER = --check-dependencies + + -- Joseph Herlant Tue, 10 Apr 2018 18:22:35 -0700 + ruby-tilt (2.0.1-2) unstable; urgency=medium * Team upload @@ -79,7 +108,7 @@ [ Youhei SASAKI ] * New Upstream Version: 1.3.3 - * control: update Build-Depends: + * control: update Build-Depends: libnokogiri-ruby{1.8,1.9.1} to ruby-nokogiri * copyright: change MIT to Expat diff -Nru ruby-tilt-2.0.1/debian/compat ruby-tilt-2.0.8/debian/compat --- ruby-tilt-2.0.1/debian/compat 2016-01-12 05:53:57.000000000 +0000 +++ ruby-tilt-2.0.8/debian/compat 2018-04-11 01:22:35.000000000 +0000 @@ -1 +1 @@ -9 +11 diff -Nru ruby-tilt-2.0.1/debian/control ruby-tilt-2.0.8/debian/control --- ruby-tilt-2.0.1/debian/control 2016-01-12 05:53:57.000000000 +0000 +++ ruby-tilt-2.0.8/debian/control 2018-04-11 01:22:35.000000000 +0000 @@ -3,8 +3,8 @@ Priority: optional Maintainer: Debian Ruby Extras Maintainers Uploaders: Youhei SASAKI -Build-Depends: debhelper (>= 9.0), - gem2deb (>= 0.3.0~), +Build-Depends: debhelper (>= 11), + gem2deb, rake, ruby-coffee-script, ruby-contest, @@ -15,16 +15,19 @@ ruby-nokogiri, ruby-test-unit, ruby-yajl -Standards-Version: 3.9.6 -Vcs-Git: git://anonscm.debian.org/pkg-ruby-extras/ruby-tilt.git -Vcs-Browser: http://anonscm.debian.org/gitweb?p=pkg-ruby-extras/ruby-tilt.git;a=summary -Homepage: http://github.com/rtomayko/tilt/ +Standards-Version: 4.1.4 +Vcs-Git: https://salsa.debian.org/ruby-team/ruby-tilt.git +Vcs-Browser: https://salsa.debian.org/ruby-team/ruby-tilt +Homepage: https://github.com/rtomayko/tilt/ +Testsuite: autopkgtest-pkg-ruby XS-Ruby-Versions: all Package: ruby-tilt Architecture: all XB-Ruby-Versions: ${ruby:Versions} -Depends: ruby | ruby-interpreter, ${misc:Depends}, ${shlibs:Depends} +Depends: ruby | ruby-interpreter, + ${misc:Depends}, + ${shlibs:Depends} Description: Generic interface to multiple Ruby template engines Tilt is a thin interface over a bunch of different Ruby template engines in an attempt to make their usage as generic possible. This is useful for web diff -Nru ruby-tilt-2.0.1/debian/copyright ruby-tilt-2.0.8/debian/copyright --- ruby-tilt-2.0.1/debian/copyright 2016-01-12 05:53:57.000000000 +0000 +++ ruby-tilt-2.0.8/debian/copyright 2018-04-11 01:22:35.000000000 +0000 @@ -1,9 +1,9 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: tilt Source: https://github.com/rtomayko/tilt/ Files: * -Copyright: Copyright (c) 2010 [Ryan Tomayko](http://tomayko.com/about) +Copyright: Copyright (c) 2010-2016 [Ryan Tomayko](http://tomayko.com/about) License: Expat Files: debian/* diff -Nru ruby-tilt-2.0.1/debian/patches/disable-failing-test.patch ruby-tilt-2.0.8/debian/patches/disable-failing-test.patch --- ruby-tilt-2.0.1/debian/patches/disable-failing-test.patch 2016-01-12 05:53:57.000000000 +0000 +++ ruby-tilt-2.0.8/debian/patches/disable-failing-test.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -Description: Disable a failing test - One of the tests fail in a weird way, which may be attributed to the fact that - upstream nokogiri uses a patched libxml2. Disabled it. -Author: Balasankar C -Last-Update: 2016-01-11 ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/test/tilt_asciidoctor_test.rb -+++ b/test/tilt_asciidoctor_test.rb -@@ -29,10 +29,10 @@ - assert_equal HTML5_OUTPUT, strip_space(template.render) - end - -- test "preparing and evaluating docbook templates on #render" do -- template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'docbook'}) { |t| "== Hello World!" } -- assert_equal DOCBOOK_OUTPUT, strip_space(template.render) -- end -+ #test "preparing and evaluating docbook templates on #render" do -+ #template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'docbook'}) { |t| "== Hello World!" } -+ #assert_equal DOCBOOK_OUTPUT, strip_space(template.render) -+ #end - - test "can be rendered more than once" do - template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'html5'}) { |t| "== Hello World!" } diff -Nru ruby-tilt-2.0.1/debian/patches/disable-less.patch ruby-tilt-2.0.8/debian/patches/disable-less.patch --- ruby-tilt-2.0.1/debian/patches/disable-less.patch 2016-01-12 05:53:57.000000000 +0000 +++ ruby-tilt-2.0.8/debian/patches/disable-less.patch 2018-04-11 01:22:35.000000000 +0000 @@ -4,12 +4,12 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/Gemfile +++ b/Gemfile -@@ -14,7 +14,7 @@ - gem 'erubis' - gem 'haml', '>= 2.2.11', '< 5' - gem 'kramdown' -- gem 'less' -+# gem 'less' - gem 'liquid' - gem 'markaby' - gem 'maruku' +@@ -20,7 +20,7 @@ + gem 'sass' + + if can_execjs +- gem 'less' ++ # gem 'less' + gem 'coffee-script' + gem 'livescript' + gem 'babel-transpiler' diff -Nru ruby-tilt-2.0.1/debian/patches/disable-markaby.patch ruby-tilt-2.0.8/debian/patches/disable-markaby.patch --- ruby-tilt-2.0.1/debian/patches/disable-markaby.patch 2016-01-12 05:53:57.000000000 +0000 +++ ruby-tilt-2.0.8/debian/patches/disable-markaby.patch 2018-04-11 01:22:35.000000000 +0000 @@ -5,11 +5,11 @@ --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ - gem 'kramdown' - # gem 'less' - gem 'liquid' + gem 'builder' + gem 'haml', '>= 4' if RUBY_VERSION >= '2.0.0' + gem 'erubis' - gem 'markaby' -+# gem 'markaby' - gem 'maruku' - gem 'nokogiri' if RUBY_VERSION > '1.9.2' - gem 'radius' ++ # gem 'markaby' + gem 'sass' + + if can_execjs diff -Nru ruby-tilt-2.0.1/debian/patches/disable-radius.patch ruby-tilt-2.0.8/debian/patches/disable-radius.patch --- ruby-tilt-2.0.1/debian/patches/disable-radius.patch 2016-01-12 05:53:57.000000000 +0000 +++ ruby-tilt-2.0.8/debian/patches/disable-radius.patch 2018-04-11 01:22:35.000000000 +0000 @@ -4,12 +4,12 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/Gemfile +++ b/Gemfile -@@ -19,7 +19,7 @@ - # gem 'markaby' - gem 'maruku' - gem 'nokogiri' if RUBY_VERSION > '1.9.2' +@@ -36,7 +36,7 @@ + gem 'creole' + gem 'kramdown' + gem 'rdoc' - gem 'radius' -+# gem 'radius' - gem 'sass' - gem 'rdoc', (ENV['RDOC_VERSION'] || '> 0') - ++ # gem 'radius' + gem 'asciidoctor', '>= 0.1.0' + gem 'liquid' + gem 'maruku' diff -Nru ruby-tilt-2.0.1/debian/patches/disable-therubyracer.patch ruby-tilt-2.0.8/debian/patches/disable-therubyracer.patch --- ruby-tilt-2.0.1/debian/patches/disable-therubyracer.patch 2016-01-12 05:53:57.000000000 +0000 +++ ruby-tilt-2.0.8/debian/patches/disable-therubyracer.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -Description: Disable requirement of therubyracer gem which is not yet packaged -Author: Pirate Praveen ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/Gemfile -+++ b/Gemfile -@@ -32,7 +32,7 @@ - end - - platform :mri do -- gem 'therubyracer' -+# gem 'therubyracer' - gem 'bluecloth' if ENV['BLUECLOTH'] - end - end diff -Nru ruby-tilt-2.0.1/debian/patches/force_encoding_erb_test ruby-tilt-2.0.8/debian/patches/force_encoding_erb_test --- ruby-tilt-2.0.1/debian/patches/force_encoding_erb_test 2015-12-23 13:33:52.000000000 +0000 +++ ruby-tilt-2.0.8/debian/patches/force_encoding_erb_test 2018-04-11 01:22:35.000000000 +0000 @@ -1,6 +1,6 @@ Description: Add Encoding.default_external to tilt_erbtemplate_test.rb When locate is not set or LANG=C, tilt_erbtemplate_test.rb is failed - because ruby can't handling UTF-8 charactor. + because ruby can't handling UTF-8 character. . This patch Add Encoding.default_external to success test. diff -Nru ruby-tilt-2.0.1/debian/patches/relax-haml-version.patch ruby-tilt-2.0.8/debian/patches/relax-haml-version.patch --- ruby-tilt-2.0.1/debian/patches/relax-haml-version.patch 2016-01-12 05:53:57.000000000 +0000 +++ ruby-tilt-2.0.8/debian/patches/relax-haml-version.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -Description: Relax the requirement on haml gem -Author: Pirate Praveen ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/Gemfile -+++ b/Gemfile -@@ -12,7 +12,7 @@ - gem 'contest' - gem 'creole' - gem 'erubis' -- gem 'haml', '>= 2.2.11', '< 4' -+ gem 'haml', '>= 2.2.11', '< 5' - gem 'kramdown' - gem 'less' - gem 'liquid' diff -Nru ruby-tilt-2.0.1/debian/patches/series ruby-tilt-2.0.8/debian/patches/series --- ruby-tilt-2.0.1/debian/patches/series 2016-01-12 05:53:57.000000000 +0000 +++ ruby-tilt-2.0.8/debian/patches/series 2018-04-11 01:22:35.000000000 +0000 @@ -1,9 +1,6 @@ force_encoding_erb_test -relax-haml-version.patch disable-less.patch disable-markaby.patch disable-radius.patch -disable-therubyracer.patch remove-bundler.patch set-available-locales.patch -disable-failing-test.patch diff -Nru ruby-tilt-2.0.1/debian/rules ruby-tilt-2.0.8/debian/rules --- ruby-tilt-2.0.1/debian/rules 2015-12-23 13:22:52.000000000 +0000 +++ ruby-tilt-2.0.8/debian/rules 2018-04-11 01:22:35.000000000 +0000 @@ -11,6 +11,8 @@ # If you need to specify the .gemspec (eg there is more than one) #export DH_RUBY_GEMSPEC=gem.gemspec +export GEM2DEB_TEST_RUNNER = --check-dependencies + %: dh $@ --buildsystem=ruby --with ruby diff -Nru ruby-tilt-2.0.1/debian/watch ruby-tilt-2.0.8/debian/watch --- ruby-tilt-2.0.1/debian/watch 2015-12-23 13:22:52.000000000 +0000 +++ ruby-tilt-2.0.8/debian/watch 2018-04-11 01:22:35.000000000 +0000 @@ -1,2 +1,2 @@ version=3 -http://pkg-ruby-extras.alioth.debian.org/cgi-bin/gemwatch/tilt .*/tilt-(.*).tar.gz +https://pkg-ruby-extras.alioth.debian.org/cgi-bin/gemwatch/tilt .*/tilt-(.*).tar.gz diff -Nru ruby-tilt-2.0.1/docs/TEMPLATES.md ruby-tilt-2.0.8/docs/TEMPLATES.md --- ruby-tilt-2.0.1/docs/TEMPLATES.md 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/docs/TEMPLATES.md 2017-08-18 22:03:01.000000000 +0000 @@ -31,11 +31,14 @@ * Sass - `Tilt::SassTemplate` * Scss - `Tilt::ScssTemplate` * CoffeeScript - `Tilt::CoffeeScriptTemplate` + * Literate CoffeeScript - `Tilt::CoffeeScriptLiterateTemplate` + * LiveScript - `Tilt::LiveScriptTemplate` * [Textile](#redcloth) - `Tilt::RedClothTemplate` + * reStructuredText - `Tilt::RstPandocTemplate` * Creole - `Tilt::CreoleTemplate` * [RDoc](#rdoc) - `Tilt::RDocTemplate` -Tilt has extensive support for Markdown, backed by one of four different +Tilt has extensive support for Markdown, backed by one of seven different implementations (depending on which are available on your system): * [Markdown](#markdown) - Generic Markdown implementation @@ -43,6 +46,8 @@ * Redcarpet - `Tilt::RedcarpetTemplate` * BlueCloth - `Tilt::BlueClothTemplate` * Kramdown - `Tilt::KramdownTemplate` + * Pandoc - `Tilt::PandocTemplate` + * CommonMarker - `Tilt::CommonMarkerTemplate` * Maruku - `Tilt::MarukuTemplate` @@ -391,6 +396,31 @@ * [RedCloth][redcloth] + +reStructuredText (`rst`) +------------------- + +reStructuredText is a lightweight markup language originally developed by David Goodger, +based on StructuredText and Setext. reStructuredText is primarily used for technical +documentation in the Python programming language community, e.g. by the +[Sphinx](http://www.sphinx-doc.org/en/stable/rest.html) Python documentation generator. + +reStructuredText formatted texts are converted to HTML with [Pandoc][pandoc], which +is an application written in Haskell, with a Ruby wrapper provided by the +[pandoc-ruby][pandoc-ruby] gem. + +### Example + + Hello Rst Templates + =================== + + Hello World. This is a paragraph. + +### See Also + + * [Pandoc][pandoc] + * [pandoc-ruby][pandoc-ruby] + RDoc (`rdoc`) @@ -431,6 +461,7 @@ * Redcarpet - `Tilt::RedcarpetTemplate` * BlueCloth - `Tilt::BlueClothTemplate` * Kramdown - `Tilt::KramdownTemplate` + * Pandoc - `Tilt::PandocTemplate` * Maruku - `Tilt::MarukuTemplate` Tilt will use fallback mode (as documented in the README) for determining which @@ -457,7 +488,7 @@ ### Options Every implementation of Markdown *should* support these options, but there are -some known problems with the Kramdown and Maruku engines. +some known problems with the Kramdown and Maruku engines. #### `:smartypants => true|false` @@ -473,7 +504,7 @@ Set `true` disallow raw HTML in Markdown contents. HTML is converted to literal text by escaping `<` characters. -Kramdown and Maruku doesn't support this option. +Kramdown and Maruku don't support this option. ### See also @@ -520,4 +551,5 @@ [rdiscount]: http://github.com/rtomayko/rdiscount/ "RDiscount" [smartypants]: http://daringfireball.net/projects/smartypants/ "Smarty Pants" [markdown]: http://en.wikipedia.org/wiki/Markdown "Markdown" - +[pandoc]: http://pandoc.org/ "Pandoc" +[pandoc-ruby]: https://github.com/alphabetum/pandoc-ruby "pandoc-ruby" diff -Nru ruby-tilt-2.0.1/Gemfile ruby-tilt-2.0.8/Gemfile --- ruby-tilt-2.0.1/Gemfile 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/Gemfile 2017-08-18 22:03:01.000000000 +0000 @@ -1,27 +1,53 @@ source 'https://rubygems.org' -gem 'yard', '~> 0.8.6' -gem 'minitest', '~> 5.0' +gemspec gem 'rake' +gem 'minitest', '~> 5.0' -group :engines do - gem 'asciidoctor', '>= 0.1.0' +group :development do + gem 'yard', '~> 0.9.0' + gem 'ronn', '~> 0.7.3' +end + +can_execjs = (RUBY_VERSION >= '1.9.3') + +group :primary do gem 'builder' - gem 'coffee-script' - gem 'contest' - gem 'creole' + gem 'haml', '>= 4' if RUBY_VERSION >= '2.0.0' gem 'erubis' - gem 'haml', '>= 2.2.11', '< 4' + gem 'markaby' + gem 'sass' + + if can_execjs + gem 'less' + gem 'coffee-script' + gem 'livescript' + gem 'babel-transpiler' + gem 'typescript-node' + end +end + +platform :mri do + gem 'duktape', '~> 1.3.0.6' if can_execjs +end + +group :secondary do + gem 'creole' gem 'kramdown' - gem 'less' + gem 'rdoc' + gem 'radius' + gem 'asciidoctor', '>= 0.1.0' gem 'liquid' - gem 'markaby' gem 'maruku' + gem 'pandoc-ruby' + + if RUBY_VERSION > '1.9.3' + gem 'prawn', '>= 2.0.0' + gem 'pdf-reader', '~> 1.3.3' + end + gem 'nokogiri' if RUBY_VERSION > '1.9.2' - gem 'radius' - gem 'sass' - gem 'rdoc', (ENV['RDOC_VERSION'] || '> 0') platform :ruby do gem 'wikicloth' @@ -29,16 +55,11 @@ gem 'redcarpet' if RUBY_VERSION > '1.8.7' gem 'rdiscount', '>= 2.1.6' if RUBY_VERSION != '1.9.2' gem 'RedCloth' + gem 'commonmarker' if RUBY_VERSION > '1.9.3' end platform :mri do - gem 'therubyracer' - gem 'bluecloth' if ENV['BLUECLOTH'] + gem 'bluecloth' end end -## WHY do I have to do this?!? -platform :rbx do - gem 'rubysl' -end - diff -Nru ruby-tilt-2.0.1/lib/tilt/babel.rb ruby-tilt-2.0.8/lib/tilt/babel.rb --- ruby-tilt-2.0.1/lib/tilt/babel.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/babel.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,16 @@ +require 'tilt/template' +require 'babel/transpiler' + +module Tilt + class BabelTemplate < Template + self.default_mime_type = 'application/javascript' + + def prepare + options[:filename] ||= file + end + + def evaluate(scope, locals, &block) + @output ||= Babel::Transpiler.transform(data)["code"] + end + end +end diff -Nru ruby-tilt-2.0.1/lib/tilt/builder.rb ruby-tilt-2.0.8/lib/tilt/builder.rb --- ruby-tilt-2.0.1/lib/tilt/builder.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/builder.rb 2017-08-18 22:03:01.000000000 +0000 @@ -2,25 +2,29 @@ require 'builder' module Tilt - # Builder template implementation. See: + # Builder template implementation. See: # http://builder.rubyforge.org/ class BuilderTemplate < Template self.default_mime_type = 'text/xml' - def prepare; end + def prepare + options[:indent] ||= 2 + end def evaluate(scope, locals, &block) - return super(scope, locals, &block) if data.respond_to?(:to_str) - xml = ::Builder::XmlMarkup.new(:indent => 2) + xml = (locals[:xml] || ::Builder::XmlMarkup.new(options)) + + if data.respond_to?(:to_str) + if !locals[:xml] + locals = locals.merge(:xml => xml) + end + return super(scope, locals, &block) + end + data.call(xml) xml.target! end - def precompiled_preamble(locals) - return super if locals.include? :xml - "xml = ::Builder::XmlMarkup.new(:indent => 2)\n#{super}" - end - def precompiled_postamble(locals) "xml.target!" end diff -Nru ruby-tilt-2.0.1/lib/tilt/coffee.rb ruby-tilt-2.0.8/lib/tilt/coffee.rb --- ruby-tilt-2.0.1/lib/tilt/coffee.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/coffee.rb 2017-08-18 22:03:01.000000000 +0000 @@ -29,10 +29,15 @@ @@default_bare = value end + def self.literate? + false + end + def prepare if !options.key?(:bare) and !options.key?(:no_wrap) options[:bare] = self.class.default_bare end + options[:literate] ||= self.class.literate? end def evaluate(scope, locals, &block) @@ -43,5 +48,11 @@ false end end + + class CoffeeScriptLiterateTemplate < CoffeeScriptTemplate + def self.literate? + true + end + end end diff -Nru ruby-tilt-2.0.1/lib/tilt/commonmarker.rb ruby-tilt-2.0.8/lib/tilt/commonmarker.rb --- ruby-tilt-2.0.1/lib/tilt/commonmarker.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/commonmarker.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,21 @@ +require 'tilt/template' +require 'commonmarker' + +module Tilt + class CommonMarkerTemplate < Template + self.default_mime_type = 'text/html' + + def prepare + @engine = nil + @output = nil + end + + def evaluate(scope, locals, &block) + CommonMarker.render_html(data, :DEFAULT) + end + + def allows_script? + false + end + end +end diff -Nru ruby-tilt-2.0.1/lib/tilt/csv.rb ruby-tilt-2.0.8/lib/tilt/csv.rb --- ruby-tilt-2.0.1/lib/tilt/csv.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/csv.rb 2017-08-18 22:03:01.000000000 +0000 @@ -45,15 +45,15 @@ end def prepare - @code =<<-RUBY - #{self.class.engine}.generate do |csv| - #{data} - end - RUBY + @outvar = options.delete(:outvar) || '_csvout' end def precompiled_template(locals) - @code + <<-RUBY + #{@outvar} = #{self.class.engine}.generate(#{options}) do |csv| + #{data} + end + RUBY end def precompiled(locals) diff -Nru ruby-tilt-2.0.1/lib/tilt/dummy.rb ruby-tilt-2.0.8/lib/tilt/dummy.rb --- ruby-tilt-2.0.1/lib/tilt/dummy.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/dummy.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,3 @@ +# Used for detecting autoloading bug in JRuby +class Tilt::Dummy; end + diff -Nru ruby-tilt-2.0.1/lib/tilt/erubi.rb ruby-tilt-2.0.8/lib/tilt/erubi.rb --- ruby-tilt-2.0.1/lib/tilt/erubi.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/erubi.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,32 @@ +require 'tilt/template' +require 'erubi' + +module Tilt + # Erubi (a simplified version of Erubis) template implementation. + # See https://github.com/jeremyevans/erubi + # + # ErubiTemplate supports the following additional options, in addition + # to the options supported by the Erubi engine: + # + # :engine_class :: allows you to specify a custom engine class to use + # instead of the default (which is ::Erubi::Engine). + class ErubiTemplate < Template + def prepare + @options.merge!(:preamble => false, :postamble => false, :ensure=>true) + + engine_class = @options[:engine_class] || Erubi::Engine + + @engine = engine_class.new(data, @options) + @outvar = @engine.bufvar + + # Remove dup after tilt supports frozen source. + @src = @engine.src.dup + + @engine + end + + def precompiled_template(locals) + @src + end + end +end diff -Nru ruby-tilt-2.0.1/lib/tilt/erubis.rb ruby-tilt-2.0.8/lib/tilt/erubis.rb --- ruby-tilt-2.0.1/lib/tilt/erubis.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/erubis.rb 2017-08-18 22:03:01.000000000 +0000 @@ -24,7 +24,7 @@ end def precompiled_preamble(locals) - [super, "#{@outvar} = _buf = ''"].join("\n") + [super, "#{@outvar} = _buf = String.new"].join("\n") end def precompiled_postamble(locals) diff -Nru ruby-tilt-2.0.1/lib/tilt/haml.rb ruby-tilt-2.0.8/lib/tilt/haml.rb --- ruby-tilt-2.0.1/lib/tilt/haml.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/haml.rb 2017-08-18 22:03:01.000000000 +0000 @@ -7,51 +7,80 @@ class HamlTemplate < Template self.default_mime_type = 'text/html' - def prepare - options = @options.merge(:filename => eval_file, :line => line) - @engine = ::Haml::Engine.new(data, options) - end + # `Gem::Version.correct?` may return false because of Haml::VERSION #=> "3.1.8 (Separated Sally)". After Haml 4, it's always correct. + if Gem::Version.correct?(Haml::VERSION) && Gem::Version.new(Haml::VERSION) >= Gem::Version.new('5.0.0.beta.2') + def prepare + options = {}.update(@options).update(filename: eval_file, line: line) + if options.include?(:outvar) + options[:buffer] = options.delete(:outvar) + options[:save_buffer] = true + end + @engine = ::Haml::TempleEngine.new(options) + @engine.compile(data) + end - def evaluate(scope, locals, &block) - if @engine.respond_to?(:precompiled_method_return_value, true) + def evaluate(scope, locals, &block) + raise ArgumentError, 'invalid scope: must not be frozen' if scope.frozen? super - else - @engine.render(scope, locals, &block) end - end - - # Precompiled Haml source. Taken from the precompiled_with_ambles - # method in Haml::Precompiler: - # http://github.com/nex3/haml/blob/master/lib/haml/precompiler.rb#L111-126 - def precompiled_template(locals) - @engine.precompiled - end - def precompiled_preamble(locals) - local_assigns = super - @engine.instance_eval do - <<-RUBY - begin - extend Haml::Helpers - _hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, #{options_for_buffer.inspect}) - _erbout = _hamlout.buffer + def precompiled_template(locals) + @engine.precompiled_with_ambles( + [], + after_preamble: <<-RUBY __in_erb_template = true _haml_locals = locals - #{local_assigns} - RUBY + RUBY + ) end - end + else # Following definitions are for Haml <= 4 and deprecated. + def prepare + options = @options.merge(:filename => eval_file, :line => line) + @engine = ::Haml::Engine.new(data, options) + end + + def evaluate(scope, locals, &block) + raise ArgumentError, 'invalid scope: must not be frozen' if scope.frozen? - def precompiled_postamble(locals) - @engine.instance_eval do - <<-RUBY - #{precompiled_method_return_value} - ensure - @haml_buffer = @haml_buffer.upper - end - RUBY + if @engine.respond_to?(:precompiled_method_return_value, true) + super + else + @engine.render(scope, locals, &block) + end + end + + # Precompiled Haml source. Taken from the precompiled_with_ambles + # method in Haml::Precompiler: + # http://github.com/nex3/haml/blob/master/lib/haml/precompiler.rb#L111-126 + def precompiled_template(locals) + @engine.precompiled + end + + def precompiled_preamble(locals) + local_assigns = super + @engine.instance_eval do + <<-RUBY + begin + extend Haml::Helpers + _hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, #{options_for_buffer.inspect}) + _erbout = _hamlout.buffer + __in_erb_template = true + _haml_locals = locals + #{local_assigns} + RUBY + end + end + + def precompiled_postamble(locals) + @engine.instance_eval do + <<-RUBY + #{precompiled_method_return_value} + ensure + @haml_buffer = @haml_buffer.upper if @haml_buffer + end + RUBY + end end end end end - diff -Nru ruby-tilt-2.0.1/lib/tilt/kramdown.rb ruby-tilt-2.0.8/lib/tilt/kramdown.rb --- ruby-tilt-2.0.1/lib/tilt/kramdown.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/kramdown.rb 2017-08-18 22:03:01.000000000 +0000 @@ -7,14 +7,6 @@ class KramdownTemplate < Template DUMB_QUOTES = [39, 39, 34, 34] - def self.engine_initialized? - defined? ::Kramdown - end - - def initialize_engine - require_template_library 'kramdown' - end - def prepare options[:smart_quotes] = DUMB_QUOTES unless options[:smartypants] @engine = Kramdown::Document.new(data, options) diff -Nru ruby-tilt-2.0.1/lib/tilt/less.rb ruby-tilt-2.0.8/lib/tilt/less.rb --- ruby-tilt-2.0.1/lib/tilt/less.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/less.rb 2017-08-18 22:03:01.000000000 +0000 @@ -9,14 +9,6 @@ class LessTemplate < Template self.default_mime_type = 'text/css' - def self.engine_initialized? - defined? ::Less - end - - def initialize_engine - require_template_library 'less' - end - def prepare if ::Less.const_defined? :Engine @engine = ::Less::Engine.new(data) diff -Nru ruby-tilt-2.0.1/lib/tilt/liquid.rb ruby-tilt-2.0.8/lib/tilt/liquid.rb --- ruby-tilt-2.0.1/lib/tilt/liquid.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/liquid.rb 2017-08-18 22:03:01.000000000 +0000 @@ -3,7 +3,7 @@ module Tilt # Liquid template implementation. See: - # http://liquid.rubyforge.org/ + # http://liquidmarkup.org/ # # Liquid is designed to be a *safe* template system and threfore # does not provide direct access to execuatable scopes. In order to @@ -17,7 +17,7 @@ # time when using this template engine. class LiquidTemplate < Template def prepare - @engine = ::Liquid::Template.parse(data) + @engine = ::Liquid::Template.parse(data, liquid_options) end def evaluate(scope, locals, &block) @@ -34,5 +34,11 @@ def allows_script? false end + + private + + def liquid_options + { line_numbers: true }.merge options + end end end diff -Nru ruby-tilt-2.0.1/lib/tilt/livescript.rb ruby-tilt-2.0.8/lib/tilt/livescript.rb --- ruby-tilt-2.0.1/lib/tilt/livescript.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/livescript.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,23 @@ +require 'tilt/template' +require 'livescript' + +module Tilt + # LiveScript template implementation. See: + # http://livescript.net/ + # + # LiveScript templates do not support object scopes, locals, or yield. + class LiveScriptTemplate < Template + self.default_mime_type = 'application/javascript' + + def prepare + end + + def evaluate(scope, locals, &block) + @output ||= LiveScript.compile(data, options) + end + + def allows_script? + false + end + end +end diff -Nru ruby-tilt-2.0.1/lib/tilt/mapping.rb ruby-tilt-2.0.8/lib/tilt/mapping.rb --- ruby-tilt-2.0.1/lib/tilt/mapping.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/mapping.rb 2017-08-18 22:03:01.000000000 +0000 @@ -1,3 +1,5 @@ +require 'monitor' + module Tilt # Tilt::Mapping associates file extensions with template implementations. # @@ -60,7 +62,7 @@ @lazy_map = other.lazy_map.dup end - # Registrers a lazy template implementation by file extension. You + # Registers a lazy template implementation by file extension. You # can have multiple lazy template implementations defined on the # same file extension, in which case the template implementation # defined *last* will be attempted loaded *first*. @@ -214,9 +216,14 @@ @template_map[ext] || lazy_load(ext) end + LOCK = Monitor.new + def lazy_load(pattern) return unless @lazy_map.has_key?(pattern) + LOCK.enter + entered = true + choices = @lazy_map[pattern] # Check if a template class is already present @@ -234,12 +241,6 @@ choices.each do |class_name, file| begin require file - - if Thread.list.size > 1 - warn "WARN: tilt autoloading '#{file}' in a non thread-safe way; " + - "explicit require '#{file}' suggested." - end - # It's safe to eval() here because constant_defined? will # raise NameError on invalid constant names template_class = eval(class_name) @@ -252,12 +253,39 @@ end raise first_failure if first_failure + ensure + LOCK.exit if entered end + # This is due to a bug in JRuby (see GH issue jruby/jruby#3585) + Tilt.autoload :Dummy, "tilt/dummy" + require "tilt/dummy" + AUTOLOAD_IS_BROKEN = Tilt.autoload?(:Dummy) + + # The proper behavior (in MRI) for autoload? is to + # return `false` when the constant/file has been + # explicitly required. + # + # However, in JRuby it returns `true` even after it's + # been required. In that case it turns out that `defined?` + # returns `"constant"` if it exists and `nil` when it doesn't. + # This is actually a second bug: `defined?` should resolve + # autoload (aka. actually try to require the file). + # + # We use the second bug in order to resolve the first bug. + def constant_defined?(name) name.split('::').inject(Object) do |scope, n| - return false if scope.autoload?(n) # skip autload - return false unless scope.const_defined?(n) + if scope.autoload?(n) + if !AUTOLOAD_IS_BROKEN + return false + end + + if eval("!defined?(scope::#{n})") + return false + end + end + return false if !scope.const_defined?(n) scope.const_get(n) end end diff -Nru ruby-tilt-2.0.1/lib/tilt/pandoc.rb ruby-tilt-2.0.8/lib/tilt/pandoc.rb --- ruby-tilt-2.0.1/lib/tilt/pandoc.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/pandoc.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,49 @@ +require 'tilt/template' +require 'pandoc-ruby' + +module Tilt + # Pandoc markdown implementation. See: + # http://pandoc.org/ + class PandocTemplate < Template + self.default_mime_type = 'text/html' + + def tilt_to_pandoc_mapping + { :smartypants => :smart, + :escape_html => { :f => 'markdown-raw_html' }, + :commonmark => { :f => 'commonmark' }, + :markdown_strict => { :f => 'markdown_strict' } + } + end + + # turn options hash into an array + # Map tilt options to pandoc options + # Replace hash keys with value true with symbol for key + # Remove hash keys with value false + # Leave other hash keys untouched + def pandoc_options + options.reduce([]) do |sum, (k,v)| + case v + when true + sum << (tilt_to_pandoc_mapping[k] || k) + when false + sum + else + sum << { k => v } + end + end + end + + def prepare + @engine = PandocRuby.new(data, *pandoc_options) + @output = nil + end + + def evaluate(scope, locals, &block) + @output ||= @engine.to_html.strip + end + + def allows_script? + false + end + end +end diff -Nru ruby-tilt-2.0.1/lib/tilt/plain.rb ruby-tilt-2.0.8/lib/tilt/plain.rb --- ruby-tilt-2.0.1/lib/tilt/plain.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/plain.rb 2017-08-18 22:03:01.000000000 +0000 @@ -6,10 +6,6 @@ class PlainTemplate < Template self.default_mime_type = 'text/html' - def self.engine_initialized? - true - end - def prepare end diff -Nru ruby-tilt-2.0.1/lib/tilt/prawn.rb ruby-tilt-2.0.8/lib/tilt/prawn.rb --- ruby-tilt-2.0.1/lib/tilt/prawn.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/prawn.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,43 @@ +require 'tilt/template' +require 'prawn' + +module Tilt + # Prawn template implementation. See: http://prawnpdf.org + # + class PrawnTemplate < Template + self.default_mime_type = 'application/pdf' + + def prepare + @engine = ::Prawn::Document.new(prawn_options) + end + + def evaluate(scope, locals, &block) + pdf = @engine + if data.respond_to?(:to_str) + locals[:pdf] = pdf + super(scope, locals, &block) + elsif data.kind_of?(Proc) + data.call(pdf) + end + @output ||= pdf.render + end + + def allows_script? + false + end + + def precompiled_template(locals) + data.to_str + end + + + private + + def prawn_options + # defaults to A4 instead of crazy US Letter format. + { :page_size => "A4", :page_layout => :portrait }.merge(options) + end + + end + +end diff -Nru ruby-tilt-2.0.1/lib/tilt/redcarpet.rb ruby-tilt-2.0.8/lib/tilt/redcarpet.rb --- ruby-tilt-2.0.1/lib/tilt/redcarpet.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/redcarpet.rb 2017-08-18 22:03:01.000000000 +0000 @@ -35,12 +35,8 @@ class Redcarpet2Template < Template self.default_mime_type = 'text/html' - def self.engine_initialized? - defined? ::Redcarpet::Render and defined? ::Redcarpet::Markdown - end - def generate_renderer - renderer = options.delete(:renderer) || ::Redcarpet::Render::HTML + renderer = options.delete(:renderer) || ::Redcarpet::Render::HTML.new(options) return renderer unless options.delete(:smartypants) return renderer if renderer.is_a?(Class) && renderer <= ::Redcarpet::Render::SmartyPants @@ -78,27 +74,10 @@ end end - # Upskirt Markdown implementation. See: - # https://github.com/tanoku/redcarpet - # - # Supports both Redcarpet 1.x and 2.x - class RedcarpetTemplate < Template - Redcarpet1 = Redcarpet1Template - Redcarpet2 = Redcarpet2Template - - def prepare - klass = Redcarpet2.engine_initialized? ? Redcarpet2 : Redcarpet1 - @engine = klass.new(file, line, options) { data } - end - - def evaluate(scope, locals, &block) - @engine.evaluate(scope, locals, &block) - end - - def allows_script? - false - end + if defined? ::Redcarpet::Render and defined? ::Redcarpet::Markdown + RedcarpetTemplate = Redcarpet2Template + else + RedcarpetTemplate = Redcarpet1Template end - end diff -Nru ruby-tilt-2.0.1/lib/tilt/rst-pandoc.rb ruby-tilt-2.0.8/lib/tilt/rst-pandoc.rb --- ruby-tilt-2.0.1/lib/tilt/rst-pandoc.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/rst-pandoc.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,18 @@ +require 'tilt/template' +require 'tilt/pandoc' + +module Tilt + # Pandoc reStructuredText implementation. See: + # http://pandoc.org/ + # Use PandocTemplate and specify input format + class RstPandocTemplate < PandocTemplate + def tilt_to_pandoc_mapping + { :smartypants => :smart } + end + + def pandoc_options + options.merge!(f: 'rst') + super + end + end +end diff -Nru ruby-tilt-2.0.1/lib/tilt/sigil.rb ruby-tilt-2.0.8/lib/tilt/sigil.rb --- ruby-tilt-2.0.1/lib/tilt/sigil.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/sigil.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,34 @@ +require 'open3' +require 'shellwords' + +module Tilt + # Standalone string interpolator and template processor implementation in Go. + # see: https://github.com/gliderlabs/sigil + class SigilTemplate < Template + def prepare + end + + def evaluate(scope, locals, &block) + variables = locals.map {|k, v| "#{k}=#{v}" } + + cmd = ['sigil'] + + unless variables.empty? + cmd << '-p' + cmd.concat(variables) + end + + out, err, status = Open3.capture3(*cmd, :stdin_data => data) + + if status.success? + out.chomp + else + raise err.chomp.gsub('', file) + end + end + + def allows_script? + false + end + end +end diff -Nru ruby-tilt-2.0.1/lib/tilt/string.rb ruby-tilt-2.0.8/lib/tilt/string.rb --- ruby-tilt-2.0.1/lib/tilt/string.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/string.rb 2017-08-18 22:03:01.000000000 +0000 @@ -6,7 +6,7 @@ class StringTemplate < Template def prepare hash = "TILT#{data.hash.abs}" - @code = "<<#{hash}.chomp\n#{data}\n#{hash}" + @code = String.new("<<#{hash}.chomp\n#{data}\n#{hash}") end def precompiled_template(locals) diff -Nru ruby-tilt-2.0.1/lib/tilt/template.rb ruby-tilt-2.0.8/lib/tilt/template.rb --- ruby-tilt-2.0.1/lib/tilt/template.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/template.rb 2017-08-18 22:03:01.000000000 +0000 @@ -2,7 +2,16 @@ module Tilt # @private - TOPOBJECT = Object.superclass || Object + TOPOBJECT = if RUBY_VERSION >= '2.0' + # @private + module CompiledTemplates + self + end + elsif RUBY_VERSION >= '1.9' + BasicObject + else + Object + end # @private LOCK = Mutex.new @@ -77,7 +86,10 @@ @data = @reader.call(self) if @data.respond_to?(:force_encoding) - @data.force_encoding(default_encoding) if default_encoding + if default_encoding + @data = @data.dup if @data.frozen? + @data.force_encoding(default_encoding) + end if !@data.valid_encoding? raise Encoding::InvalidByteSequenceError, "#{eval_file} is not valid #{@data.encoding}" @@ -90,7 +102,8 @@ # Render the template in the given scope with the locals specified. If a # block is given, it is typically available within the template via # +yield+. - def render(scope=Object.new, locals={}, &block) + def render(scope=nil, locals={}, &block) + scope ||= Object.new current_template = Thread.current[:tilt_current_template] Thread.current[:tilt_current_template] = self evaluate(scope, locals || {}, &block) @@ -151,7 +164,9 @@ # This method is only used by source generating templates. Subclasses that # override render() may not support all features. def evaluate(scope, locals, &block) - method = compiled_method(locals.keys) + locals_keys = locals.keys + locals_keys.sort!{|x, y| x.to_s <=> y.to_s} + method = compiled_method(locals_keys) method.bind(scope).call(locals, &block) end @@ -168,7 +183,7 @@ preamble = precompiled_preamble(local_keys) template = precompiled_template(local_keys) postamble = precompiled_postamble(local_keys) - source = '' + source = String.new # Ensure that our generated source code has the same encoding as the # the source code generated by the template engine. @@ -237,10 +252,10 @@ local_code = local_extraction(local_keys) method_name = "__tilt_#{Thread.current.object_id.abs}" - method_source = "" + method_source = String.new if method_source.respond_to?(:force_encoding) - method_source.force_encoding(source.encoding) + method_source.force_encoding(source.encoding) end method_source << <<-RUBY @@ -249,6 +264,7 @@ Thread.current[:tilt_vars] = [self, locals] class << self this, locals = Thread.current[:tilt_vars] + locals = locals this.instance_eval do #{local_code} RUBY diff -Nru ruby-tilt-2.0.1/lib/tilt/typescript.rb ruby-tilt-2.0.8/lib/tilt/typescript.rb --- ruby-tilt-2.0.1/lib/tilt/typescript.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt/typescript.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,26 @@ +require 'tilt/template' +require 'typescript-node' + +module Tilt + class TypeScriptTemplate < Template + self.default_mime_type = 'application/javascript' + + def prepare + @option_args = [] + + options.each do |key, value| + next unless value + + @option_args << "--#{key}" + + if value != true + @option_args << value.to_s + end + end + end + + def evaluate(scope, locals, &block) + @output ||= TypeScript::Node.compile(data, *@option_args) + end + end +end diff -Nru ruby-tilt-2.0.1/lib/tilt.rb ruby-tilt-2.0.8/lib/tilt.rb --- ruby-tilt-2.0.1/lib/tilt.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/lib/tilt.rb 2017-08-18 22:03:01.000000000 +0000 @@ -4,7 +4,7 @@ # Namespace for Tilt. This module is not intended to be included anywhere. module Tilt # Current version. - VERSION = '2.0.1' + VERSION = '2.0.8' @default_mapping = Mapping.new @@ -78,14 +78,31 @@ # cache.fetch(path, line, options) { Tilt.new(path, line, options) } # # Subsequent invocations return the already loaded template object. + # + # @note + # Tilt::Cache is a thin wrapper around Hash. It has the following + # limitations: + # * Not thread-safe. + # * Size is unbounded. + # * Keys are not copied defensively, and should not be modified after + # being passed to #fetch. More specifically, the values returned by + # key#hash and key#eql? should not change. + # If this is too limiting for you, use a different cache implementation. class Cache def initialize @cache = {} end - # @see Cache + # Caches a value for key, or returns the previously cached value. + # If a value has been previously cached for key then it is + # returned. Otherwise, block is yielded to and its return value + # which may be nil, is cached under key and returned. + # @yield + # @yieldreturn the value to cache for key def fetch(*key) - @cache[key] ||= yield + @cache.fetch(key) do + @cache[key] = yield + end end # Clears the cache. @@ -100,33 +117,43 @@ # ERB register_lazy :ERBTemplate, 'tilt/erb', 'erb', 'rhtml' register_lazy :ErubisTemplate, 'tilt/erubis', 'erb', 'rhtml', 'erubis' + register_lazy :ErubiTemplate, 'tilt/erubi', 'erb', 'rhtml', 'erubi' # Markdown - register_lazy :BlueClothTemplate, 'tilt/bluecloth', 'markdown', 'mkd', 'md' - register_lazy :MarukuTemplate, 'tilt/maruku', 'markdown', 'mkd', 'md' - register_lazy :KramdownTemplate, 'tilt/kramdown', 'markdown', 'mkd', 'md' - register_lazy :RDiscountTemplate, 'tilt/rdiscount', 'markdown', 'mkd', 'md' - register_lazy :RedcarpetTemplate, 'tilt/redcarpet', 'markdown', 'mkd', 'md' + register_lazy :BlueClothTemplate, 'tilt/bluecloth', 'markdown', 'mkd', 'md' + register_lazy :MarukuTemplate, 'tilt/maruku', 'markdown', 'mkd', 'md' + register_lazy :KramdownTemplate, 'tilt/kramdown', 'markdown', 'mkd', 'md' + register_lazy :RDiscountTemplate, 'tilt/rdiscount', 'markdown', 'mkd', 'md' + register_lazy :RedcarpetTemplate, 'tilt/redcarpet', 'markdown', 'mkd', 'md' + register_lazy :CommonMarkerTemplate, 'tilt/commonmarker', 'markdown', 'mkd', 'md' + register_lazy :PandocTemplate, 'tilt/pandoc', 'markdown', 'mkd', 'md' # Rest (sorted by name) register_lazy :AsciidoctorTemplate, 'tilt/asciidoc', 'ad', 'adoc', 'asciidoc' + register_lazy :BabelTemplate, 'tilt/babel', 'es6', 'babel', 'jsx' register_lazy :BuilderTemplate, 'tilt/builder', 'builder' register_lazy :CSVTemplate, 'tilt/csv', 'rcsv' register_lazy :CoffeeScriptTemplate, 'tilt/coffee', 'coffee' + register_lazy :CoffeeScriptLiterateTemplate, 'tilt/coffee', 'litcoffee' register_lazy :CreoleTemplate, 'tilt/creole', 'wiki', 'creole' register_lazy :EtanniTemplate, 'tilt/etanni', 'etn', 'etanni' register_lazy :HamlTemplate, 'tilt/haml', 'haml' register_lazy :LessTemplate, 'tilt/less', 'less' register_lazy :LiquidTemplate, 'tilt/liquid', 'liquid' + register_lazy :LiveScriptTemplate, 'tilt/livescript','ls' register_lazy :MarkabyTemplate, 'tilt/markaby', 'mab' register_lazy :NokogiriTemplate, 'tilt/nokogiri', 'nokogiri' register_lazy :PlainTemplate, 'tilt/plain', 'html' + register_lazy :PrawnTemplate, 'tilt/prawn', 'prawn' register_lazy :RDocTemplate, 'tilt/rdoc', 'rdoc' register_lazy :RadiusTemplate, 'tilt/radius', 'radius' register_lazy :RedClothTemplate, 'tilt/redcloth', 'textile' + register_lazy :RstPandocTemplate, 'tilt/rst-pandoc', 'rst' register_lazy :SassTemplate, 'tilt/sass', 'sass' register_lazy :ScssTemplate, 'tilt/sass', 'scss' + register_lazy :SigilTemplate, 'tilt/sigil', 'sigil' register_lazy :StringTemplate, 'tilt/string', 'str' + register_lazy :TypeScriptTemplate, 'tilt/typescript', 'ts', 'tsx' register_lazy :WikiClothTemplate, 'tilt/wikicloth', 'wiki', 'mediawiki', 'mw' register_lazy :YajlTemplate, 'tilt/yajl', 'yajl' @@ -134,4 +161,6 @@ register_lazy 'Slim::Template', 'slim', 'slim' register_lazy 'Tilt::HandlebarsTemplate', 'tilt/handlebars', 'handlebars', 'hbs' register_lazy 'Tilt::OrgTemplate', 'org-ruby', 'org' + register_lazy 'Opal::Processor', 'opal', 'opal', 'rb' + register_lazy 'Tilt::JbuilderTemplate', 'tilt/jbuilder', 'jbuilder' end diff -Nru ruby-tilt-2.0.1/man/index.txt ruby-tilt-2.0.8/man/index.txt --- ruby-tilt-2.0.1/man/index.txt 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/man/index.txt 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,2 @@ +m4(1) http://man.cx/m4(1) +mustache(1) https://mustache.github.io/mustache.1.html diff -Nru ruby-tilt-2.0.1/man/tilt.1.ronn ruby-tilt-2.0.8/man/tilt.1.ronn --- ruby-tilt-2.0.1/man/tilt.1.ronn 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/man/tilt.1.ronn 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,59 @@ +tilt(1) -- process templates +============================ + +## SYNOPSIS + +`tilt` `-l`
+`tilt` [`-t` ] [`-y` ] [`-D` =] [`-d` ] + [`--vars=`] + +## DESCRIPTION + +Process template and write output to stdout. With no or +when is '-', read template from stdin and use the --type option +to determine the template's type. + +## OPTIONS + +* `-l`, `--list`: + List template engines + file patterns and exit +* `-t`, `--type`=: + Use this template engine; required if no +* `-y`, `--layout`=: + Use as a layout template +* `-D`=: + Define variable as +* `-d`, `--define-file`=: + Load YAML or JSON from and use for variables +* `--vars`=: + Evaluate to Hash and use for variables +* `-h`, `--help`: + Show this help message + +## EXAMPLES + +Convert markdown to HTML: + + $ tilt foo.markdown > foo.html + +Process ERB template: + + $ echo "Answer: <%= 2 + 2 %>" | tilt -t erb + Answer: 4 + +Define variables: + + $ echo '{"n":40}' > data.json + $ echo "Answer: <%= 2 + n %>" | tilt -t erb -d data.json + Answer: 42 + + $ echo "Answer: <%= 2 + n %>" | tilt -t erb --vars="{:n=>40}" + Answer: 42 + $ echo "Answer: <%= 2 + n.to_i %>" | tilt -t erb -Dn=40 + Answer: 42 + +## SEE ALSO + +m4(1), mustache(1) + + diff -Nru ruby-tilt-2.0.1/metadata.yml ruby-tilt-2.0.8/metadata.yml --- ruby-tilt-2.0.1/metadata.yml 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/metadata.yml 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ ---- !ruby/object:Gem::Specification -name: tilt -version: !ruby/object:Gem::Version - version: 2.0.1 -platform: ruby -authors: -- Ryan Tomayko -autorequire: -bindir: bin -cert_chain: [] -date: 2014-03-21 00:00:00.000000000 Z -dependencies: [] -description: Generic interface to multiple Ruby template engines -email: r@tomayko.com -executables: -- tilt -extensions: [] -extra_rdoc_files: [] -files: -- CHANGELOG.md -- COPYING -- Gemfile -- HACKING -- README.md -- Rakefile -- bin/tilt -- docs/TEMPLATES.md -- docs/common.css -- lib/tilt.rb -- lib/tilt/asciidoc.rb -- lib/tilt/bluecloth.rb -- lib/tilt/builder.rb -- lib/tilt/coffee.rb -- lib/tilt/creole.rb -- lib/tilt/csv.rb -- lib/tilt/erb.rb -- lib/tilt/erubis.rb -- lib/tilt/etanni.rb -- lib/tilt/haml.rb -- lib/tilt/kramdown.rb -- lib/tilt/less.rb -- lib/tilt/liquid.rb -- lib/tilt/mapping.rb -- lib/tilt/markaby.rb -- lib/tilt/maruku.rb -- lib/tilt/nokogiri.rb -- lib/tilt/plain.rb -- lib/tilt/radius.rb -- lib/tilt/rdiscount.rb -- lib/tilt/rdoc.rb -- lib/tilt/redcarpet.rb -- lib/tilt/redcloth.rb -- lib/tilt/sass.rb -- lib/tilt/string.rb -- lib/tilt/template.rb -- lib/tilt/wikicloth.rb -- lib/tilt/yajl.rb -- test/markaby/locals.mab -- test/markaby/markaby.mab -- test/markaby/markaby_other_static.mab -- test/markaby/render_twice.mab -- test/markaby/scope.mab -- test/markaby/yielding.mab -- test/test_helper.rb -- test/tilt_asciidoctor_test.rb -- test/tilt_blueclothtemplate_test.rb -- test/tilt_buildertemplate_test.rb -- test/tilt_cache_test.rb -- test/tilt_coffeescripttemplate_test.rb -- test/tilt_compilesite_test.rb -- test/tilt_creoletemplate_test.rb -- test/tilt_csv_test.rb -- test/tilt_erbtemplate_test.rb -- test/tilt_erubistemplate_test.rb -- test/tilt_etannitemplate_test.rb -- test/tilt_hamltemplate_test.rb -- test/tilt_kramdown_test.rb -- test/tilt_lesstemplate_test.less -- test/tilt_lesstemplate_test.rb -- test/tilt_liquidtemplate_test.rb -- test/tilt_mapping_test.rb -- test/tilt_markaby_test.rb -- test/tilt_markdown_test.rb -- test/tilt_marukutemplate_test.rb -- test/tilt_metadata_test.rb -- test/tilt_nokogiritemplate_test.rb -- test/tilt_radiustemplate_test.rb -- test/tilt_rdiscounttemplate_test.rb -- test/tilt_rdoctemplate_test.rb -- test/tilt_redcarpettemplate_test.rb -- test/tilt_redclothtemplate_test.rb -- test/tilt_sasstemplate_test.rb -- test/tilt_stringtemplate_test.rb -- test/tilt_template_test.rb -- test/tilt_test.rb -- test/tilt_wikiclothtemplate_test.rb -- test/tilt_yajltemplate_test.rb -- tilt.gemspec -homepage: http://github.com/rtomayko/tilt/ -licenses: -- MIT -metadata: {} -post_install_message: -rdoc_options: -- "--line-numbers" -- "--inline-source" -- "--title" -- Tilt -- "--main" -- Tilt -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: '0' -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: '0' -requirements: [] -rubyforge_project: -rubygems_version: 2.2.1 -signing_key: -specification_version: 2 -summary: Generic interface to multiple Ruby template engines -test_files: -- test/tilt_asciidoctor_test.rb -- test/tilt_blueclothtemplate_test.rb -- test/tilt_buildertemplate_test.rb -- test/tilt_cache_test.rb -- test/tilt_coffeescripttemplate_test.rb -- test/tilt_compilesite_test.rb -- test/tilt_creoletemplate_test.rb -- test/tilt_csv_test.rb -- test/tilt_erbtemplate_test.rb -- test/tilt_erubistemplate_test.rb -- test/tilt_etannitemplate_test.rb -- test/tilt_hamltemplate_test.rb -- test/tilt_kramdown_test.rb -- test/tilt_lesstemplate_test.rb -- test/tilt_liquidtemplate_test.rb -- test/tilt_mapping_test.rb -- test/tilt_markaby_test.rb -- test/tilt_markdown_test.rb -- test/tilt_marukutemplate_test.rb -- test/tilt_metadata_test.rb -- test/tilt_nokogiritemplate_test.rb -- test/tilt_radiustemplate_test.rb -- test/tilt_rdiscounttemplate_test.rb -- test/tilt_rdoctemplate_test.rb -- test/tilt_redcarpettemplate_test.rb -- test/tilt_redclothtemplate_test.rb -- test/tilt_sasstemplate_test.rb -- test/tilt_stringtemplate_test.rb -- test/tilt_template_test.rb -- test/tilt_test.rb -- test/tilt_wikiclothtemplate_test.rb -- test/tilt_yajltemplate_test.rb -has_rdoc: diff -Nru ruby-tilt-2.0.1/Rakefile ruby-tilt-2.0.8/Rakefile --- ruby-tilt-2.0.1/Rakefile 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/Rakefile 2017-08-18 22:03:01.000000000 +0000 @@ -11,23 +11,34 @@ t.test_files = FileList['test/*_test.rb'] t.ruby_opts = ['-Itest'] t.ruby_opts << '-rubygems' if defined? Gem + t.warning = false end # DOCUMENTATION ============================================================= -require 'yard' -YARD::Rake::YardocTask.new do |t| - t.files = [ - 'lib/tilt.rb', 'lib/tilt/mapping.rb', 'lib/tilt/template.rb', - '-', - '*.md', 'docs/*.md', - ] +begin + require 'yard' + YARD::Rake::YardocTask.new do |t| + t.files = [ + 'lib/tilt.rb', 'lib/tilt/mapping.rb', 'lib/tilt/template.rb', + '-', + '*.md', 'docs/*.md', + ] - t.options << - '--no-private' << - '--protected' << - '-m' << 'markdown' << - '--asset' << 'docs/common.css:css/common.css' + t.options << + '--no-private' << + '--protected' << + '-m' << 'markdown' << + '--asset' << 'docs/common.css:css/common.css' + end +rescue LoadError +end + +task :man do + require 'ronn' + ENV['RONN_MANUAL'] = "Tilt Manual" + ENV['RONN_ORGANIZATION'] = "Tilt #{SPEC.version}" + sh "ronn -w -s toc -r5 --markdown man/*.ronn" end # PACKAGING ================================================================= diff -Nru ruby-tilt-2.0.1/README.md ruby-tilt-2.0.8/README.md --- ruby-tilt-2.0.1/README.md 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/README.md 2017-08-18 22:03:01.000000000 +0000 @@ -1,4 +1,4 @@ -Tilt [![Build Status](https://secure.travis-ci.org/rtomayko/tilt.png)](http://travis-ci.org/rtomayko/tilt) [![Dependency Status](https://gemnasium.com/rtomayko/tilt.png)](https://gemnasium.com/rtomayko/tilt) +Tilt [![Build Status](https://secure.travis-ci.org/rtomayko/tilt.svg)](http://travis-ci.org/rtomayko/tilt) [![Dependency Status](https://gemnasium.com/rtomayko/tilt.svg)](https://gemnasium.com/rtomayko/tilt) [![Inline docs](http://inch-ci.org/github/rtomayko/tilt.svg)](http://inch-ci.org/github/rtomayko/tilt) [![Security](https://hakiri.io/github/rtomayko/tilt/master.svg)](https://hakiri.io/github/rtomayko/tilt/master) ==== **NOTE** The following file documents the current release of Tilt (2.0). See @@ -24,44 +24,71 @@ Support for these template engines is included with the package: - ENGINE FILE EXTENSIONS REQUIRED LIBRARIES - -------------------------- ----------------------- ---------------------------- - Asciidoctor .ad, .adoc, .asciidoc asciidoctor (>= 0.1.0) - ERB .erb, .rhtml none (included ruby stdlib) - Interpolated String .str none (included ruby core) - Erubis .erb, .rhtml, .erubis erubis - Haml .haml haml - Sass .sass haml (< 3.1) or sass (>= 3.1) - Scss .scss haml (< 3.1) or sass (>= 3.1) - Less CSS .less less - Builder .builder builder - Liquid .liquid liquid - RDiscount .markdown, .mkd, .md rdiscount - Redcarpet .markdown, .mkd, .md redcarpet - BlueCloth .markdown, .mkd, .md bluecloth - Kramdown .markdown, .mkd, .md kramdown - Maruku .markdown, .mkd, .md maruku - RedCloth .textile redcloth - RDoc .rdoc rdoc - Radius .radius radius - Markaby .mab markaby - Nokogiri .nokogiri nokogiri - CoffeeScript .coffee coffee-script (+ javascript) - Creole (Wiki markup) .wiki, .creole creole - WikiCloth (Wiki markup) .wiki, .mediawiki, .mw wikicloth - Yajl .yajl yajl-ruby - CSV .rcsv none (Ruby >= 1.9), fastercsv (Ruby < 1.9) +| Engine | File Extensions | Required Libraries | Maintainer | +| ----------------------- | ---------------------- | ------------------------------------------ | ----------- | +| Asciidoctor | .ad, .adoc, .asciidoc | asciidoctor (>= 0.1.0) | Community | +| ERB | .erb, .rhtml | none (included ruby stdlib) | Tilt team | +| InterpolatedString | .str | none (included ruby core) | Tilt team | +| Erubi | .erb, .rhtml, .erubi | erubi | Community | +| Erubis | .erb, .rhtml, .erubis | erubis | Tilt team | +| Haml | .haml | haml | Tilt team | +| Sass | .sass | haml (< 3.1) or sass (>= 3.1) | Tilt team | +| Scss | .scss | haml (< 3.1) or sass (>= 3.1) | Tilt team | +| Less CSS | .less | less | Tilt team | +| Builder | .builder | builder | Tilt team | +| Liquid | .liquid | liquid | Community | +| RDiscount | .markdown, .mkd, .md | rdiscount | Community | +| Redcarpet | .markdown, .mkd, .md | redcarpet | Community | +| BlueCloth | .markdown, .mkd, .md | bluecloth | Community | +| Kramdown | .markdown, .mkd, .md | kramdown | Community | +| Pandoc | .markdown, .mkd, .md | pandoc | Community | +| reStructuredText | .rst | pandoc | Community | +| Maruku | .markdown, .mkd, .md | maruku | Community | +| CommonMarker | .markdown, .mkd, .md | commonmarker | Community | +| RedCloth | .textile | redcloth | Community | +| RDoc | .rdoc | rdoc | Tilt team | +| Radius | .radius | radius | Community | +| Markaby | .mab | markaby | Tilt team | +| Nokogiri | .nokogiri | nokogiri | Community | +| CoffeeScript | .coffee | coffee-script (+ javascript) | Tilt team | +| CoffeeScript (literate) | .litcoffee | coffee-script (>= 1.5.0) (+ javascript) | Tilt team | +| LiveScript | .ls | livescript (+ javascript) | Tilt team | +| TypeScript | .ts | typescript (+ javascript) | Tilt team | +| Creole (Wiki markup) | .wiki, .creole | creole | Community | +| WikiCloth (Wiki markup) | .wiki, .mediawiki, .mw | wikicloth | Community | +| Yajl | .yajl | yajl-ruby | Community | +| CSV | .rcsv | none (Ruby >= 1.9), fastercsv (Ruby < 1.9) | Tilt team | +| Prawn | .prawn | prawn (>= 2.0.0) | Community | +| Babel | .es6, .babel, .jsx | babel-transpiler | Tilt team | +| Opal | .rb | opal | Community | +| Sigil | .sigil | sigil | Community | + +Every supported template engine has a *maintainer*. Note that this is the +maintainer of the Tilt integration, not the maintainer of the template engine +itself. The maintainer is responsible for providing an adequate integration and +keeping backwards compatibility across Tilt version. Some integrations are +maintained by the *community*, which is handled in the following way: + +- The Tilt team will liberally accept pull requests against the template + integration. It's up to the community as a whole to make sure the integration + stays consistent and backwards compatible over time. +- Test failures in community-maintained integrations will not be prioritized by + the Tilt team and a new version of Tilt might be released even though these + tests are failing. +- Anyone can become a maintainer for a template engine integration they care + about. Just open an issue and we'll figure it out. These template engines ship with their own Tilt integration: - ENGINE FILE EXTENSIONS REQUIRED LIBRARIES - -------------------------- ----------------- ---------------------------- - Slim .slim slim (>= 0.7) - Embedded JavaScript sprockets - Embedded CoffeeScript sprockets - JST sprockets - Org-mode .org org-ruby (>= 0.6.2) - Handlebars .hbs, .handlebars tilt-handlebars +| Engine | File Extensions | Required Libraries | +| ------------------- | ---------------- | ------------------- | +| Slim | .slim | slim (>= 0.7) | +| Embedded JavaScript | | sprockets | +| Embedded CoffeeScript | | sprockets | +| JST | | sprockets | +| Org-mode | .org | org-ruby (>= 0.6.2) | +| Handlebars | .hbs, handlebars | tilt-handlebars | +| Jbuilder | .jbuilder | tilt-jbuilder | See [TEMPLATES.md][t] for detailed information on template engine options and supported features. @@ -77,7 +104,7 @@ require 'erb' require 'tilt' template = Tilt.new('templates/foo.erb') - => # + => # output = template.render => "Hello world!" diff -Nru ruby-tilt-2.0.1/test/mytemplate.rb ruby-tilt-2.0.8/test/mytemplate.rb --- ruby-tilt-2.0.1/test/mytemplate.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/test/mytemplate.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,2 @@ +class MyTemplate +end diff -Nru ruby-tilt-2.0.1/test/tilt_asciidoctor_test.rb ruby-tilt-2.0.8/test/tilt_asciidoctor_test.rb --- ruby-tilt-2.0.1/test/tilt_asciidoctor_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_asciidoctor_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -6,7 +6,8 @@ class AsciidoctorTemplateTest < Minitest::Test HTML5_OUTPUT = "

Hello World!

" - DOCBOOK_OUTPUT = "
Hello World!
" + DOCBOOK45_OUTPUT = "
Hello World!
" + DOCBOOK5_OUTPUT = "
Hello World!
" def strip_space(str) str.gsub(/>\s+<').strip @@ -29,9 +30,14 @@ assert_equal HTML5_OUTPUT, strip_space(template.render) end - test "preparing and evaluating docbook templates on #render" do - template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'docbook'}) { |t| "== Hello World!" } - assert_equal DOCBOOK_OUTPUT, strip_space(template.render) + test "preparing and evaluating docbook 4.5 templates on #render" do + template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'docbook45'}) { |t| "== Hello World!" } + assert_equal DOCBOOK45_OUTPUT, strip_space(template.render) + end + + test "preparing and evaluating docbook 5 templates on #render" do + template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'docbook5'}) { |t| "== Hello World!" } + assert_equal DOCBOOK5_OUTPUT, strip_space(template.render) end test "can be rendered more than once" do @@ -39,6 +45,6 @@ 3.times { assert_equal HTML5_OUTPUT, strip_space(template.render) } end end -rescue LoadError => boom +rescue LoadError warn "Tilt::AsciidoctorTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_babeltemplate.rb ruby-tilt-2.0.8/test/tilt_babeltemplate.rb --- ruby-tilt-2.0.1/test/tilt_babeltemplate.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_babeltemplate.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,33 @@ +require 'test_helper' +require 'tilt' + +begin + require 'tilt/babel' + + class BabelTemplateTest < Minitest::Test + test "registered for '.es6' files" do + assert_equal Tilt::BabelTemplate, Tilt['es6'] + end + + test "registered for '.babel' files" do + assert_equal Tilt::BabelTemplate, Tilt['babel'] + end + + test "registered for '.jsx' files" do + assert_equal Tilt::BabelTemplate, Tilt['jsx'] + end + + test "basic ES6 features" do + template = Tilt::BabelTemplate.new { "square = (x) => x * x" } + assert_match "function", template.render + end + + test "JSX support" do + template = Tilt::BabelTemplate.new { "" } + assert_match "React.createElement", template.render + end + end +rescue LoadError => boom + warn "Tilt::BabelTemplate (disabled)" +end + diff -Nru ruby-tilt-2.0.1/test/tilt_blueclothtemplate_test.rb ruby-tilt-2.0.8/test/tilt_blueclothtemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_blueclothtemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_blueclothtemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -28,6 +28,6 @@ assert_equal "

HELLO <blink>WORLD</blink>

", template.render end end -rescue LoadError => boom +rescue LoadError warn "Tilt::BlueClothTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_buildertemplate_test.rb ruby-tilt-2.0.8/test/tilt_buildertemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_buildertemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_buildertemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -44,6 +44,19 @@ assert_equal "Hey Joe!\n", template.render end + test "options can be overridden" do + template = Tilt::BuilderTemplate.new(:indent => 0) { "xml.div { xml.em('Hey') }" } + assert_equal "
Hey
", template.render + end + + test "can re-use locals for multiple calls" do + locals = { :name => "world" } + template = Tilt::BuilderTemplate.new(:indent => 0) { "xml.em name" } + 3.times do + assert_equal "world", template.render(self, locals) + end + end + test "allows nesting raw XML" do subtemplate = Tilt::BuilderTemplate.new { "xml.em 'Hello World!'" } template = Tilt::BuilderTemplate.new { "xml.strong { xml << yield }" } diff -Nru ruby-tilt-2.0.1/test/tilt_cache_test.rb ruby-tilt-2.0.8/test/tilt_cache_test.rb --- ruby-tilt-2.0.1/test/tilt_cache_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_cache_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -20,6 +20,17 @@ assert_same template, result end + test "caching nil" do + called = false + result = @cache.fetch("blah") {called = true; nil} + assert_equal true, called + assert_nil result + called = false + result = @cache.fetch("blah") {called = true; :blah} + assert_equal false, called + assert_nil result + end + test "clearing the cache with #clear" do template, other = nil result = @cache.fetch('hello') { template = Tilt::StringTemplate.new {''} } diff -Nru ruby-tilt-2.0.1/test/tilt_coffeescripttemplate_test.rb ruby-tilt-2.0.8/test/tilt_coffeescripttemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_coffeescripttemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_coffeescripttemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -4,101 +4,138 @@ begin require 'tilt/coffee' - class CoffeeScriptTemplateTest < Minitest::Test - - test "is registered for '.coffee' files" do - assert_equal Tilt::CoffeeScriptTemplate, Tilt['test.coffee'] + module CoffeeScriptTests + def self.included(mod) + mod.class_eval do + test "bare is disabled by default" do + assert_equal false, @renderer.default_bare + end + + test "compiles and evaluates the template on #render" do + template = @renderer.new { |t| @code_without_variables } + assert_match "puts('Hello, World!');", template.render + end + + test "can be rendered more than once" do + template = @renderer.new { |t| @code_without_variables } + 3.times { assert_match "puts('Hello, World!');", template.render } + end + + test "disabling coffee-script wrapper" do + template = @renderer.new { @code_with_variables } + assert_match "(function() {", template.render + assert_match "puts(\"Hello, \" + name);\n", template.render + + template = @renderer.new(:bare => true) { @code_with_variables } + refute_match "(function() {", template.render + assert_equal "var name;\n\nname = \"Josh\";\n\nputs(\"Hello, \" + name);\n", template.render + + template = @renderer.new(:no_wrap => true) { @code_with_variables} + refute_match "(function() {", template.render + assert_equal "var name;\n\nname = \"Josh\";\n\nputs(\"Hello, \" + name);\n", template.render + end + + context "wrapper globally enabled" do + setup do + @bare = @renderer.default_bare + @renderer.default_bare = false + end + + teardown do + @renderer.default_bare = @bare + end + + test "no options" do + template = @renderer.new { |t| @code_with_variables } + assert_match "puts(\"Hello, \" + name);", template.render + assert_match "(function() {", template.render + end + + test "overridden by :bare" do + template = @renderer.new(:bare => true) { |t| @code_with_variables } + assert_match "puts(\"Hello, \" + name);", template.render + refute_match "(function() {", template.render + end + + test "overridden by :no_wrap" do + template = @renderer.new(:no_wrap => true) { |t| @code_with_variables } + assert_match "puts(\"Hello, \" + name);", template.render + refute_match "(function() {", template.render + end + end + + context "wrapper globally disabled" do + setup do + @bare = @renderer.default_bare + @renderer.default_bare = true + end + + teardown do + @renderer.default_bare = @bare + end + + test "no options" do + template = @renderer.new { |t| @code_with_variables } + assert_match "puts(\"Hello, \" + name);", template.render + refute_match "(function() {", template.render + end + + test "overridden by :bare" do + template = @renderer.new(:bare => false) { |t| @code_with_variables } + assert_match "puts(\"Hello, \" + name);", template.render + assert_match "(function() {", template.render + end + + test "overridden by :no_wrap" do + template = @renderer.new(:no_wrap => false) { |t| @code_with_variables } + assert_match "puts(\"Hello, \" + name);", template.render + assert_match "(function() {", template.render + end + end + end end + end - test "bare is disabled by default" do - assert_equal false, Tilt::CoffeeScriptTemplate.default_bare + class CoffeeScriptTemplateTest < Minitest::Test + setup do + @code_without_variables = "puts 'Hello, World!'\n" + @code_with_variables = 'name = "Josh"; puts "Hello, #{name}"' + @renderer = Tilt::CoffeeScriptTemplate end - test "compiles and evaluates the template on #render" do - template = Tilt::CoffeeScriptTemplate.new { |t| "puts 'Hello, World!'\n" } - assert_match "puts('Hello, World!');", template.render - end + include CoffeeScriptTests - test "can be rendered more than once" do - template = Tilt::CoffeeScriptTemplate.new { |t| "puts 'Hello, World!'\n" } - 3.times { assert_match "puts('Hello, World!');", template.render } + test "is registered for '.coffee' files" do + assert_equal @renderer, Tilt['test.coffee'] end + end - test "disabling coffee-script wrapper" do - str = 'name = "Josh"; puts "Hello #{name}"' + class LiterateCoffeeScriptTemplateTest < Minitest::Test + setup do + @code_without_variables = < true) { str } - refute_match "(function() {", template.render - assert_equal "var name;\n\nname = \"Josh\";\n\nputs(\"Hello \" + name);\n", template.render - - template2 = Tilt::CoffeeScriptTemplate.new(:no_wrap => true) { str} - refute_match "(function() {", template.render - assert_equal "var name;\n\nname = \"Josh\";\n\nputs(\"Hello \" + name);\n", template.render - end + puts 'Hello, World!' - context "wrapper globally enabled" do - setup do - @bare = Tilt::CoffeeScriptTemplate.default_bare - Tilt::CoffeeScriptTemplate.default_bare = false - end +This is a comment too. +EOLIT + @code_with_variables = < true) { |t| 'name = "Josh"; puts "Hello, #{name}"' } - assert_match "puts(\"Hello, \" + name);", template.render - refute_match "(function() {", template.render - end - - test "overridden by :no_wrap" do - template = Tilt::CoffeeScriptTemplate.new(:no_wrap => true) { |t| 'name = "Josh"; puts "Hello, #{name}"' } - assert_match "puts(\"Hello, \" + name);", template.render - refute_match "(function() {", template.render - end +This is a comment too. +EOLIT + @renderer = Tilt::CoffeeScriptLiterateTemplate end - context "wrapper globally disabled" do - setup do - @bare = Tilt::CoffeeScriptTemplate.default_bare - Tilt::CoffeeScriptTemplate.default_bare = true - end - - teardown do - Tilt::CoffeeScriptTemplate.default_bare = @bare - end - - test "no options" do - template = Tilt::CoffeeScriptTemplate.new { |t| 'name = "Josh"; puts "Hello, #{name}"' } - assert_match "puts(\"Hello, \" + name);", template.render - refute_match "(function() {", template.render - end + include CoffeeScriptTests - test "overridden by :bare" do - template = Tilt::CoffeeScriptTemplate.new(:bare => false) { |t| 'name = "Josh"; puts "Hello, #{name}"' } - assert_match "puts(\"Hello, \" + name);", template.render - assert_match "(function() {", template.render - end - - test "overridden by :no_wrap" do - template = Tilt::CoffeeScriptTemplate.new(:no_wrap => false) { |t| 'name = "Josh"; puts "Hello, #{name}"' } - assert_match "puts(\"Hello, \" + name);", template.render - assert_match "(function() {", template.render - end + test "is registered for '.litcoffee' files" do + assert_equal @renderer, Tilt['test.litcoffee'] end end -rescue LoadError => boom +rescue LoadError warn "Tilt::CoffeeScriptTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_commonmarkertemplate_test.rb ruby-tilt-2.0.8/test/tilt_commonmarkertemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_commonmarkertemplate_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_commonmarkertemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,20 @@ +require 'test_helper' +require 'tilt' + +begin + require 'tilt/commonmarker' + + class CommonMarkerTemplateTest < Minitest::Test + test "preparing and evaluating templates on #render" do + template = Tilt::CommonMarkerTemplate.new { |t| "# Hello World!" } + assert_equal "

Hello World!

\n", template.render + end + + test "can be rendered more than once" do + template = Tilt::CommonMarkerTemplate.new { |t| "# Hello World!" } + 3.times { assert_equal "

Hello World!

\n", template.render } + end + end +rescue LoadError + warn "Tilt::CommonMarkerTemplate (disabled)" +end diff -Nru ruby-tilt-2.0.1/test/tilt_creoletemplate_test.rb ruby-tilt-2.0.8/test/tilt_creoletemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_creoletemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_creoletemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -19,6 +19,6 @@ 3.times { assert_equal "

Hello World!

", template.render } end end -rescue LoadError => boom +rescue LoadError warn "Tilt::CreoleTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_csv_test.rb ruby-tilt-2.0.8/test/tilt_csv_test.rb --- ruby-tilt-2.0.1/test/tilt_csv_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_csv_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -42,14 +42,26 @@ assert_kind_of NameError, boom line = boom.backtrace.grep(/^test\.csv:/).first assert line, "Backtrace didn't contain test.csv" - file, line, meth = line.split(":") + _file, line, _meth = line.split(":") assert_equal '4', line end end + test "passing options to engine" do + template = Tilt::CSVTemplate.new(:col_sep => '|') { 'csv << [1,2,3]' } + assert_equal "1|2|3\n", template.render + end + + test "outvar option" do + outvar = '@_output' + scope = Object.new + template = Tilt::CSVTemplate.new(:outvar => outvar) { 'csv << [1,2,3]' } + output = template.render(scope) + assert_equal output, scope.instance_variable_get(outvar.to_sym) + end end -rescue LoadError => boom +rescue LoadError warn "Tilt::CSVTemplate (disabled) please install 'fastercsv' if using ruby 1.8.x" end diff -Nru ruby-tilt-2.0.1/test/tilt_erbtemplate_test.rb ruby-tilt-2.0.8/test/tilt_erbtemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_erbtemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_erbtemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -68,7 +68,7 @@ assert_kind_of NameError, boom line = boom.backtrace.grep(/^test\.erb:/).first assert line, "Backtrace didn't contain test.erb" - file, line, meth = line.split(":") + _file, line, _meth = line.split(":") assert_equal '13', line end end @@ -83,7 +83,7 @@ rescue => boom assert_kind_of RuntimeError, boom line = boom.backtrace.first - file, line, meth = line.split(":") + file, line, _meth = line.split(":") assert_equal 'test.erb', file assert_equal '6', line end @@ -170,7 +170,7 @@ assert_kind_of NameError, boom line = boom.backtrace.grep(/^test\.erb:/).first assert line, "Backtrace didn't contain test.erb" - file, line, meth = line.split(":") + _file, line, _meth = line.split(":") assert_equal '13', line end end @@ -185,7 +185,7 @@ rescue => boom assert_kind_of RuntimeError, boom line = boom.backtrace.first - file, line, meth = line.split(":") + file, line, _meth = line.split(":") assert_equal 'test.erb', file assert_equal '6', line end diff -Nru ruby-tilt-2.0.1/test/tilt_erubistemplate_test.rb ruby-tilt-2.0.8/test/tilt_erubistemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_erubistemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_erubistemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -74,7 +74,7 @@ assert_kind_of NameError, boom line = boom.backtrace.grep(/^test\.erubis:/).first assert line, "Backtrace didn't contain test.erubis" - file, line, meth = line.split(":") + _file, line, _meth = line.split(":") assert_equal '13', line end end @@ -89,7 +89,7 @@ rescue => boom assert_kind_of RuntimeError, boom line = boom.backtrace.first - file, line, meth = line.split(":") + file, line, _meth = line.split(":") assert_equal 'test.erubis', file assert_equal '6', line end @@ -132,11 +132,11 @@ test "does not modify options argument" do options_hash = {:escape_html => true} - template = Tilt::ErubisTemplate.new(nil, options_hash) { |t| "Hello World!" } + Tilt::ErubisTemplate.new(nil, options_hash) { |t| "Hello World!" } assert_equal({:escape_html => true}, options_hash) end end -rescue LoadError => boom +rescue LoadError warn "Tilt::ErubisTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_erubitemplate_test.rb ruby-tilt-2.0.8/test/tilt_erubitemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_erubitemplate_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_erubitemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,158 @@ +require 'test_helper' +require 'tilt' + +begin + require 'tilt/erubi' + class ErubiTemplateTest < Minitest::Test + test "registered for '.erubi' files" do + assert_equal Tilt::ErubiTemplate, Tilt['test.erubi'] + assert_equal Tilt::ErubiTemplate, Tilt['test.html.erubi'] + end + + test "registered above ERB and Erubis" do + %w[erb rhtml].each do |ext| + lazy = Tilt.lazy_map[ext] + erubi_idx = lazy.index { |klass, file| klass == 'Tilt::ErubiTemplate' } + erubis_idx = lazy.index { |klass, file| klass == 'Tilt::ErubisTemplate' } + erb_idx = lazy.index { |klass, file| klass == 'Tilt::ERBTemplate' } + assert erubi_idx < erubis_idx, + "#{erubi_idx} should be lower than #{erubis_idx}" + assert erubi_idx < erb_idx, + "#{erubi_idx} should be lower than #{erb_idx}" + end + end + + test "preparing and evaluating templates on #render" do + template = Tilt::ErubiTemplate.new { |t| "Hello World!" } + assert_equal "Hello World!", template.render + end + + test "can be rendered more than once" do + template = Tilt::ErubiTemplate.new { |t| "Hello World!" } + 3.times { assert_equal "Hello World!", template.render } + end + + test "passing locals" do + template = Tilt::ErubiTemplate.new { 'Hey <%= name %>!' } + assert_equal "Hey Joe!", template.render(Object.new, :name => 'Joe') + end + + test "evaluating in an object scope" do + template = Tilt::ErubiTemplate.new { 'Hey <%= @name %>!' } + scope = Object.new + scope.instance_variable_set :@name, 'Joe' + assert_equal "Hey Joe!", template.render(scope) + end + + class MockOutputVariableScope + attr_accessor :exposed_buffer + end + + test "exposing the buffer to the template by default" do + template = Tilt::ErubiTemplate.new(nil, :bufvar=>'@_out_buf') { '<% self.exposed_buffer = @_out_buf %>hey' } + scope = MockOutputVariableScope.new + template.render(scope) + refute_nil scope.exposed_buffer + assert_equal scope.exposed_buffer, 'hey' + end + + test "passing a block for yield" do + template = Tilt::ErubiTemplate.new { 'Hey <%= yield %>!' } + assert_equal "Hey Joe!", template.render { 'Joe' } + end + + test "backtrace file and line reporting without locals" do + data = File.read(__FILE__).split("\n__END__\n").last + fail unless data[0] == ?< + template = Tilt::ErubiTemplate.new('test.erubis', 11) { data } + begin + template.render + fail 'should have raised an exception' + rescue => boom + assert_kind_of NameError, boom + line = boom.backtrace.grep(/^test\.erubis:/).first + assert line, "Backtrace didn't contain test.erubis" + _file, line, _meth = line.split(":") + assert_equal '13', line + end + end + + test "backtrace file and line reporting with locals" do + data = File.read(__FILE__).split("\n__END__\n").last + fail unless data[0] == ?< + template = Tilt::ErubiTemplate.new('test.erubis', 1) { data } + begin + template.render(nil, :name => 'Joe', :foo => 'bar') + fail 'should have raised an exception' + rescue => boom + assert_kind_of RuntimeError, boom + line = boom.backtrace.first + file, line, _meth = line.split(":") + assert_equal 'test.erubis', file + assert_equal '6', line + end + end + + test "erubis template options" do + template = Tilt::ErubiTemplate.new(nil, :escapefunc=> 'h') { 'Hey <%== @name %>!' } + scope = Object.new + def scope.h(s) s * 2 end + scope.instance_variable_set :@name, 'Joe' + assert_equal "Hey JoeJoe!", template.render(scope) + end + + test "using an instance variable as the outvar" do + template = Tilt::ErubiTemplate.new(nil, :outvar => '@buf') { "<%= 1 + 1 %>" } + scope = Object.new + scope.instance_variable_set(:@buf, 'original value') + assert_equal '2', template.render(scope) + assert_equal 'original value', scope.instance_variable_get(:@buf) + end + + test "using Erubi::CaptureEndEngine subclass via :engine_class option" do + require 'erubi/capture_end' + def self.bar + @a << "a" + yield + @a << 'b' + @a.upcase + end + template = Tilt::ErubiTemplate.new(nil, :engine_class => ::Erubi::CaptureEndEngine, :bufvar=>'@a') { 'c<%|= bar do %>d<%| end %>e' } + assert_equal "cADBe", template.render(self) + end + + test "using :escape_html => true option" do + template = Tilt::ErubiTemplate.new(nil, :escape_html => true) { |t| %(<%= "

Hello World!

" %>) } + assert_equal "<p>Hello World!</p>", template.render + end + + test "using :escape_html => false option" do + template = Tilt::ErubiTemplate.new(nil, :escape_html => false) { |t| %(<%= "

Hello World!

" %>) } + assert_equal "

Hello World!

", template.render + end + + test "erubi default does not escape html" do + template = Tilt::ErubiTemplate.new { |t| %(<%= "

Hello World!

" %>) } + assert_equal "

Hello World!

", template.render + end + + test "does not modify options argument" do + options_hash = {:escape_html => true} + Tilt::ErubiTemplate.new(nil, options_hash) { |t| "Hello World!" } + assert_equal({:escape_html => true}, options_hash) + end + end +rescue LoadError + warn "Tilt::ErubiTemplate (disabled)" +end + +__END__ + + +

Hey <%= name %>!

+ + +

<% fail %>

+ + + diff -Nru ruby-tilt-2.0.1/test/tilt_etannitemplate_test.rb ruby-tilt-2.0.8/test/tilt_etannitemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_etannitemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_etannitemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -55,7 +55,7 @@ assert_kind_of NameError, boom line = boom.backtrace.grep(/^test\.etn:/).first assert line, "Backtrace didn't contain test.etn" - file, line, meth = line.split(":") + _file, line, _meth = line.split(":") assert_equal '13', line end end @@ -70,7 +70,7 @@ rescue => boom assert_kind_of RuntimeError, boom line = boom.backtrace.first - file, line, meth = line.split(":") + file, line, _meth = line.split(":") assert_equal 'test.etn', file assert_equal '6', line end @@ -141,7 +141,7 @@ line = boom.backtrace.first line = boom.backtrace.grep(/^test\.etn:/).first assert line, "Backtrace didn't contain test.etn" - file, line, meth = line.split(":") + _file, line, _meth = line.split(":") assert_equal '13', line end end @@ -156,7 +156,7 @@ rescue => boom assert_kind_of RuntimeError, boom line = boom.backtrace.first - file, line, meth = line.split(":") + file, line, _meth = line.split(":") assert_equal 'test.etn', file assert_equal '6', line end diff -Nru ruby-tilt-2.0.1/test/tilt_hamltemplate_test.rb ruby-tilt-2.0.8/test/tilt_hamltemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_hamltemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_hamltemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -27,6 +27,17 @@ assert_equal "

Hey Joe!

\n", template.render(Object.new, :name => 'Joe') end + test 'evaluating in default/nil scope' do + template = Tilt::HamlTemplate.new { |t| '%p Hey unknown!' } + assert_equal "

Hey unknown!

\n", template.render + assert_equal "

Hey unknown!

\n", template.render(nil) + end + + test 'evaluating in invalid, frozen scope' do + template = Tilt::HamlTemplate.new { |t| '%p Hey unknown!' } + assert_raises(ArgumentError) { template.render(Object.new.freeze) } + end + test "evaluating in an object scope" do template = Tilt::HamlTemplate.new { "%p= 'Hey ' + @name + '!'" } scope = Object.new @@ -50,7 +61,7 @@ assert_kind_of NameError, boom line = boom.backtrace.grep(/^test\.haml:/).first assert line, "Backtrace didn't contain test.haml" - file, line, meth = line.split(":") + _file, line, _meth = line.split(":") assert_equal '12', line end end @@ -60,11 +71,11 @@ fail unless data[0] == ?% template = Tilt::HamlTemplate.new('test.haml') { data } begin - res = template.render(Object.new, :name => 'Joe', :foo => 'bar') + template.render(Object.new, :name => 'Joe', :foo => 'bar') rescue => boom assert_kind_of MockError, boom line = boom.backtrace.first - file, line, meth = line.split(":") + file, line, _meth = line.split(":") assert_equal 'test.haml', file assert_equal '5', line end @@ -87,6 +98,17 @@ assert_equal "

Hey Joe!

\n", template.render(Scope.new, :name => 'Joe') end + test 'evaluating in default/nil scope' do + template = Tilt::HamlTemplate.new { |t| '%p Hey unknown!' } + assert_equal "

Hey unknown!

\n", template.render + assert_equal "

Hey unknown!

\n", template.render(nil) + end + + test 'evaluating in invalid, frozen scope' do + template = Tilt::HamlTemplate.new { |t| '%p Hey unknown!' } + assert_raises(ArgumentError) { template.render(Object.new.freeze) } + end + test "evaluating in an object scope" do template = Tilt::HamlTemplate.new { "%p= 'Hey ' + @name + '!'" } scope = Scope.new @@ -110,7 +132,7 @@ assert_kind_of NameError, boom line = boom.backtrace.grep(/^test\.haml:/).first assert line, "Backtrace didn't contain test.haml" - file, line, meth = line.split(":") + _file, line, _meth = line.split(":") assert_equal '12', line end end @@ -120,17 +142,17 @@ fail unless data[0] == ?% template = Tilt::HamlTemplate.new('test.haml') { data } begin - res = template.render(Scope.new, :name => 'Joe', :foo => 'bar') + template.render(Scope.new, :name => 'Joe', :foo => 'bar') rescue => boom assert_kind_of MockError, boom line = boom.backtrace.first - file, line, meth = line.split(":") + file, line, _meth = line.split(":") assert_equal 'test.haml', file assert_equal '5', line end end end -rescue LoadError => boom +rescue LoadError warn "Tilt::HamlTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_kramdown_test.rb ruby-tilt-2.0.8/test/tilt_kramdown_test.rb --- ruby-tilt-2.0.1/test/tilt_kramdown_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_kramdown_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -15,6 +15,6 @@ 3.times { assert_equal '

Hello World!

', template.render.strip } end end -rescue LoadError => boom +rescue LoadError warn "Tilt::KramdownTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_lesstemplate_test.rb ruby-tilt-2.0.8/test/tilt_lesstemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_lesstemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_lesstemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -37,6 +37,6 @@ end end -rescue LoadError => boom +rescue LoadError warn "Tilt::LessTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_liquidtemplate_test.rb ruby-tilt-2.0.8/test/tilt_liquidtemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_liquidtemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_liquidtemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -24,6 +24,15 @@ assert_equal "Hey Joe!", template.render(nil, :name => 'Joe') end + test "options can be set" do + err = assert_raises(Liquid::SyntaxError) do + options = { line_numbers: false, error_mode: :strict } + Tilt::LiquidTemplate.new(options) { "{{%%%}}" }.render + end + assert_equal 'Liquid syntax error: Unexpected character % in "{{%%%}}"', + err.message + end + # Object's passed as "scope" to LiquidTemplate may respond to # #to_h with a Hash. The Hash's contents are merged underneath # Tilt locals. @@ -73,6 +82,6 @@ end end -rescue LoadError => boom +rescue LoadError warn "Tilt::LiquidTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_livescripttemplate_test.rb ruby-tilt-2.0.8/test/tilt_livescripttemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_livescripttemplate_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_livescripttemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,37 @@ +require 'test_helper' +require 'tilt' + +begin + require 'tilt/livescript' + + class LiveScriptTemplateTest < Minitest::Test + setup do + @code_without_variables = "puts 'Hello, World!'\n" + @renderer = Tilt::LiveScriptTemplate + end + + test "compiles and evaluates the template on #render" do + template = @renderer.new { |t| @code_without_variables } + assert_match "puts('Hello, World!');", template.render + end + + test "can be rendered more than once" do + template = @renderer.new { |t| @code_without_variables } + 3.times { assert_match "puts('Hello, World!');", template.render } + end + + test "supports bare-option" do + template = @renderer.new(:bare => false) { |t| @code_without_variables } + assert_match "function", template.render + + template = @renderer.new(:bare => true) { |t| @code_without_variables } + refute_match "function", template.render + end + + test "is registered for '.ls' files" do + assert_equal @renderer, Tilt['test.ls'] + end + end +rescue LoadError + warn "Tilt::LiveScriptTemplate (disabled)" +end diff -Nru ruby-tilt-2.0.1/test/tilt_mapping_test.rb ruby-tilt-2.0.8/test/tilt_mapping_test.rb --- ruby-tilt-2.0.1/test/tilt_mapping_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_mapping_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -57,10 +57,12 @@ context "lazy with one template class" do setup do @mapping.register_lazy('MyTemplate', 'my_template', 'mt') + @loaded_before = $LOADED_FEATURES.dup end teardown do Object.send :remove_const, :MyTemplate if defined? ::MyTemplate + $LOADED_FEATURES.replace(@loaded_before) end test "registered?" do @@ -97,6 +99,21 @@ end end + test "doesn't require when the template class is autoloaded, and then defined" do + Object.autoload :MyTemplate, 'mytemplate' + did_load = require 'mytemplate' + assert did_load, "mytemplate wasn't freshly required" + + req = proc do |file| + flunk "#require shouldn't be called" + end + + @mapping.stub :require, req do + klass = @mapping['hello.mt'] + assert_equal ::MyTemplate, klass + end + end + test "raises NameError when the class name is defined" do req = proc do |file| # do nothing @@ -108,20 +125,6 @@ end end end - - test "warns when there's multiple threads" do - Thread.new do - req = proc do |file| - class ::MyTemplate; end - end - - @mapping.stub :require, req do - assert_output '', /autoloading 'my_template'/ do - @mapping['hello.mt'] - end - end - end.join - end end context "lazy with two template classes" do @@ -185,7 +188,7 @@ @mapping.stub :require, req do err = assert_raises(LoadError) do - klass = @mapping['hello.mt'] + @mapping['hello.mt'] end assert_equal 'my_template2', err.message diff -Nru ruby-tilt-2.0.1/test/tilt_markaby_test.rb ruby-tilt-2.0.8/test/tilt_markaby_test.rb --- ruby-tilt-2.0.1/test/tilt_markaby_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_markaby_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -83,6 +83,6 @@ end end -rescue LoadError => boom +rescue LoadError warn "Tilt::MarkabyTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_markdown_test.rb ruby-tilt-2.0.8/test/tilt_markdown_test.rb --- ruby-tilt-2.0.1/test/tilt_markdown_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_markdown_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -91,13 +91,16 @@ class MarkdownRedcarpetTest < Minitest::Test include MarkdownTests template Tilt::RedcarpetTemplate - # Doesn't support escaping - undef test_escape_html_true def test_smarty_pants_true # Various versions of Redcarpet support various versions of Smart pants. html = nrender "Hello ``World'' -- This is --- a test ...", :smartypants => true - assert_match /

Hello “World(''|”) – This is — a test …<\/p>/, html + assert_match %r!

Hello “World(''|”) – This is — a test …<\/p>!, html + end + + def test_renderer_options + html = nrender "Hello [World](http://example.com)", :smartypants => true, :no_links => true + assert_equal "

Hello [World](http://example.com)

", html end def test_fenced_code_blocks_with_lang @@ -171,4 +174,13 @@ warn "Markdown tests need Nokogiri" end +begin + require 'tilt/pandoc' + class MarkdownPandocTest < Minitest::Test + include MarkdownTests + template Tilt::PandocTemplate + end +rescue LoadError => boom + # It should already be warned in the main tests +end diff -Nru ruby-tilt-2.0.1/test/tilt_marukutemplate_test.rb ruby-tilt-2.0.8/test/tilt_marukutemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_marukutemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_marukutemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -31,6 +31,6 @@ assert_equal "

HELLO

", template.render.strip end end -rescue LoadError => boom +rescue LoadError warn "Tilt::MarukuTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_pandoctemplate_test.rb ruby-tilt-2.0.8/test/tilt_pandoctemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_pandoctemplate_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_pandoctemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,67 @@ +# encoding: utf-8 + +require 'test_helper' +require 'tilt' + +begin + require 'tilt/pandoc' + + class PandocTemplateTest < Minitest::Test + test "preparing and evaluating templates on #render" do + template = Tilt::PandocTemplate.new { |t| "# Hello World!" } + assert_equal "

Hello World!

", template.render + end + + test "can be rendered more than once" do + template = Tilt::PandocTemplate.new { |t| "# Hello World!" } + 3.times { assert_equal "

Hello World!

", template.render } + end + + test "smartypants when :smartypants is set" do + template = Tilt::PandocTemplate.new(:smartypants => true) { |t| "OKAY -- 'Smarty Pants'" } + assert_equal "

OKAY – ‘Smarty Pants’

", template.render + end + + test "stripping HTML when :escape_html is set" do + template = Tilt::PandocTemplate.new(:escape_html => true) { |t| "HELLO WORLD" } + assert_equal "

HELLO <blink>WORLD</blink>

", template.render + end + + # Pandoc has tons of additional markdown features (see http://pandoc.org/README.html#pandocs-markdown). + # The test for footnotes should be seen as a general representation for all of them. + # use markdown_strict => true to disable additional markdown features + describe "passing in Pandoc options" do + test "generates footnotes" do + template = Tilt::PandocTemplate.new { |t| "Here is an inline note.^[Inlines notes are cool!]" } + assert_equal "

Here is an inline note.1

\n
\n
\n
    \n
  1. Inlines notes are cool!

  2. \n
\n
", template.render + end + + test "doesn't generate footnotes with markdown_strict option" do + template = Tilt::PandocTemplate.new(:markdown_strict => true) { |t| "Here is an inline note.^[Inlines notes are cool!]" } + assert_equal "

Here is an inline note.^[Inlines notes are cool!]

", template.render + end + + test "doesn't generate footnotes with commonmark option" do + template = Tilt::PandocTemplate.new(:commonmark => true) { |t| "Here is an inline note.^[Inlines notes are cool!]" } + assert_equal "

Here is an inline note.^[Inlines notes are cool!]

", template.render + end + + test "accepts arguments with values (e.g. :id_prefix => 'xyz')" do + # Table of contents isn't on by default + template = Tilt::PandocTemplate.new { |t| "# This is a heading" } + assert_equal "

This is a heading

", template.render + + # But it can be activated + template = Tilt::PandocTemplate.new(:id_prefix => 'test-') { |t| "# This is a heading" } + assert_equal "

This is a heading

", template.render + end + + test "requires arguments without value (e.g. --standalone) to be passed as hash keys (:standalone => true)" do + template = Tilt::PandocTemplate.new(:standalone => true) { |t| "# This is a heading" } + assert_match(/^This is a heading<\/h1>.*<\/html>$/m, template.render) + end + end + end +rescue LoadError + warn "Tilt::PandocTemplate (disabled)" +end diff -Nru ruby-tilt-2.0.1/test/tilt_prawntemplate.prawn ruby-tilt-2.0.8/test/tilt_prawntemplate.prawn --- ruby-tilt-2.0.1/test/tilt_prawntemplate.prawn 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_prawntemplate.prawn 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1 @@ +pdf.text "Hello Template!" \ No newline at end of file diff -Nru ruby-tilt-2.0.1/test/tilt_prawntemplate_test.rb ruby-tilt-2.0.8/test/tilt_prawntemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_prawntemplate_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_prawntemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,75 @@ +require 'test_helper' +require 'tilt' + +begin + require 'tilt/prawn' + require 'pdf-reader' + + class PdfOutput + def initialize(pdf_raw) + @reader = PDF::Reader.new(StringIO.new(pdf_raw)) + end + + def text + @reader.pages.map(&:text).join + end + + def page_attributes(page_num=1) + @reader.page(page_num).attributes + end + end + + class PrawnTemplateTest < Minitest::Test + test "is registered for '.prawn' files" do + assert_equal Tilt::PrawnTemplate, Tilt['test.prawn'] + end + + test "compiles and evaluates the template on #render" do + template = Tilt::PrawnTemplate.new { |t| "pdf.text \"Hello PDF!\"" } + output = PdfOutput.new(template.render) + assert_includes output.text, "Hello PDF!" + end + + test "can be rendered more than once" do + template = Tilt::PrawnTemplate.new { |t| "pdf.text \"Hello PDF!\"" } + 3.times do + output = PdfOutput.new(template.render) + assert_includes output.text, "Hello PDF!" + end + end + + test "loads the template from a file and renders it correctly" do + template = Tilt::PrawnTemplate.new("#{Dir.pwd}/test/tilt_prawntemplate.prawn") + output = PdfOutput.new(template.render) + assert_includes output.text, "Hello Template!" + end + + test "loads the template from a file and can be rendered more than once" do + template = Tilt::PrawnTemplate.new("#{Dir.pwd}/test/tilt_prawntemplate.prawn") + 3.times do + output = PdfOutput.new(template.render) + assert_includes output.text, "Hello Template!" + end + end + + test "have the correct default page size & layout settings - (default: A4 portrait)" do + # NOTE! Dear North Americans, + # Please follow the ISO 216 international standard format (A4) that dominates everywhere else in the world + template = Tilt::PrawnTemplate.new { |t| "pdf.text \"Hello A4 portrait!\"" } + output = PdfOutput.new(template.render) + assert_includes output.text, "Hello A4 portrait!" + assert_equal [0, 0, 595.28, 841.89], output.page_attributes(1)[:MediaBox] + end + + test "allows page size & layout settings - A3 landscape" do + template = Tilt::PrawnTemplate.new( :page_size => 'A3', :page_layout => :landscape) { |t| "pdf.text \"Hello A3 landscape!\"" } + output = PdfOutput.new(template.render) + assert_includes output.text, "Hello A3 landscape!" + assert_equal [0, 0, 1190.55, 841.89], output.page_attributes(1)[:MediaBox] + end + + end + +rescue LoadError + warn "Tilt::PrawnTemplate (disabled)" +end diff -Nru ruby-tilt-2.0.1/test/tilt_radiustemplate_test.rb ruby-tilt-2.0.8/test/tilt_radiustemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_radiustemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_radiustemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -69,7 +69,7 @@ end end -rescue LoadError => boom +rescue LoadError warn "Tilt::RadiusTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_rdiscounttemplate_test.rb ruby-tilt-2.0.8/test/tilt_rdiscounttemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_rdiscounttemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_rdiscounttemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -38,6 +38,6 @@ assert_equal "

HELLO <blink>WORLD</blink>

\n", template.render end end -rescue LoadError => boom +rescue LoadError warn "Tilt::RDiscountTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_rdoctemplate_test.rb ruby-tilt-2.0.8/test/tilt_rdoctemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_rdoctemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_rdoctemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -11,16 +11,16 @@ test "preparing and evaluating the template with #render" do template = Tilt::RDocTemplate.new { |t| "= Hello World!" } result = template.render.strip - assert_match /

Hello World!Hello World!<), result end test "can be rendered more than once" do template = Tilt::RDocTemplate.new { |t| "= Hello World!" } 3.times do result = template.render.strip - assert_match /

Hello World!Hello World!<), result end end end diff -Nru ruby-tilt-2.0.1/test/tilt_redcarpettemplate_test.rb ruby-tilt-2.0.8/test/tilt_redcarpettemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_redcarpettemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_redcarpettemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -25,11 +25,6 @@ end end - test "redcarpet2 is our default choice" do - template = Tilt::RedcarpetTemplate.new {} - assert_equal Tilt::RedcarpetTemplate::Redcarpet2, template.prepare.class - end - test "preparing and evaluating templates on #render" do template = Tilt::RedcarpetTemplate.new { |t| "# Hello World!" } assert_equal "

Hello World!

\n", template.render @@ -43,17 +38,17 @@ test "smartypants when :smart is set" do template = Tilt::RedcarpetTemplate.new(:smartypants => true) { |t| "OKAY -- 'Smarty Pants'" } - assert_match /

OKAY – ('|‘)Smarty Pants('|’)<\/p>/, + assert_match %r!

OKAY – ('|‘)Smarty Pants('|’)<\/p>!, template.render end test "smartypants with a rendererer instance" do template = Tilt::RedcarpetTemplate.new(:renderer => Redcarpet::Render::HTML.new(:hard_wrap => true), :smartypants => true) { |t| "OKAY -- 'Smarty Pants'" } - assert_match /

OKAY – ('|‘)Smarty Pants('|’)<\/p>/, + assert_match %r!

OKAY – ('|‘)Smarty Pants('|’)<\/p>!, template.render end end -rescue LoadError => boom +rescue LoadError warn "Tilt::RedcarpetTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_redclothtemplate_test.rb ruby-tilt-2.0.8/test/tilt_redclothtemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_redclothtemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_redclothtemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -31,6 +31,6 @@ assert_equal "

But they can be\nturned off.

", template.render end end -rescue LoadError => boom +rescue LoadError warn "Tilt::RedClothTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_rstpandoctemplate_test.rb ruby-tilt-2.0.8/test/tilt_rstpandoctemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_rstpandoctemplate_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_rstpandoctemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,32 @@ +require 'test_helper' +require 'tilt' + +begin + require 'tilt/rst-pandoc' + + class RstPandocTemplateTest < Minitest::Test + test "is registered for '.rst' files" do + assert_equal Tilt::RstPandocTemplate, Tilt['test.rst'] + end + + test "compiles and evaluates the template on #render" do + template = Tilt::RstPandocTemplate.new { |t| "Hello World!\n============" } + assert_equal "

Hello World!

", template.render + end + + test "can be rendered more than once" do + template = Tilt::RstPandocTemplate.new { |t| "Hello World!\n============" } + 3.times do + assert_equal "

Hello World!

", template.render + end + end + + test "doens't use markdown options" do + template = Tilt::RstPandocTemplate.new(:escape_html => true) { |t| "HELLO WORLD" } + err = assert_raises(RuntimeError) { template.render } + assert_match %r(pandoc: unrecognized option `--escape-html), err.message + end + end +rescue LoadError => boom + warn "Tilt::RstPandocTemplate (disabled) [#{boom}]" +end diff -Nru ruby-tilt-2.0.1/test/tilt_sasstemplate_test.rb ruby-tilt-2.0.8/test/tilt_sasstemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_sasstemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_sasstemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -36,6 +36,6 @@ end end -rescue LoadError => boom +rescue LoadError warn "Tilt::SassTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/test/tilt_sigil_test.rb ruby-tilt-2.0.8/test/tilt_sigil_test.rb --- ruby-tilt-2.0.1/test/tilt_sigil_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_sigil_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,41 @@ +require 'test_helper' +require 'tilt' +require 'tilt/sigil' + +system('sigil -v') + +if $?.success? + class SigilTemplateTest < Minitest::Test + test "registered for '.sigil' files" do + assert_equal Tilt::SigilTemplate, Tilt['test.sigil'] + end + + test "loading and evaluating templates on #render" do + template = Tilt::SigilTemplate.new { |t| "Hello World!" } + assert_equal "Hello World!", template.render + end + + test "can be rendered more than once" do + template = Tilt::SigilTemplate.new { |t| "Hello World!" } + 3.times { assert_equal "Hello World!", template.render } + end + + test "passing locals" do + template = Tilt::SigilTemplate.new { 'Hey $name!' } + assert_equal "Hey Joe!", template.render(Object.new, :name => 'Joe') + end + + test "error message" do + template = Tilt::SigilTemplate.new('test.sigil') { '{{undef_func}}' } + begin + template.render + fail 'should have raised an exception' + rescue => boom + assert_kind_of RuntimeError, boom + assert_equal 'template: test.sigil:1: function "undef_func" not defined', boom.message + end + end + end +else + warn "Tilt::SigilTemplate (disabled)" +end diff -Nru ruby-tilt-2.0.1/test/tilt_stringtemplate_test.rb ruby-tilt-2.0.8/test/tilt_stringtemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_stringtemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_stringtemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -51,7 +51,7 @@ assert_kind_of NameError, boom line = boom.backtrace.grep(/^test\.str:/).first assert line, "Backtrace didn't contain test.str" - file, line, meth = line.split(":") + _file, line, _meth = line.split(":") assert_equal '13', line end end @@ -66,7 +66,7 @@ rescue => boom assert_kind_of RuntimeError, boom line = boom.backtrace.first - file, line, meth = line.split(":") + file, line, _meth = line.split(":") assert_equal 'test.str', file assert_equal '6', line end @@ -138,7 +138,7 @@ line = boom.backtrace.first line = boom.backtrace.grep(/^test\.str:/).first assert line, "Backtrace didn't contain test.str" - file, line, meth = line.split(":") + _file, line, _meth = line.split(":") assert_equal '13', line end end @@ -153,7 +153,7 @@ rescue => boom assert_kind_of RuntimeError, boom line = boom.backtrace.first - file, line, meth = line.split(":") + file, line, _meth = line.split(":") assert_equal 'test.str', file assert_equal '6', line end diff -Nru ruby-tilt-2.0.1/test/tilt_template_test.rb ruby-tilt-2.0.8/test/tilt_template_test.rb --- ruby-tilt-2.0.1/test/tilt_template_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_template_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -75,20 +75,6 @@ MockTemplate.new { |template| "Hello World!" } end - class InitializingMockTemplate < Tilt::Template - @@initialized_count = 0 - def self.initialized_count - @@initialized_count - end - - def initialize_engine - @@initialized_count += 1 - end - - def prepare - end - end - class PreparingMockTemplate < Tilt::Template def prepare raise "data must be set" if data.nil? @@ -122,6 +108,12 @@ assert inst.prepared? end + test 'prepares and evaluates the template on #render with nil arg' do + inst = SimpleMockTemplate.new { |t| "Hello World!" } + assert_equal 'Hello World!', inst.render(nil) + assert inst.prepared? + end + class SourceGeneratingMockTemplate < PreparingMockTemplate def precompiled_template(locals) "foo = [] ; foo << %Q{#{data}} ; foo.join" @@ -140,6 +132,12 @@ assert inst.prepared? end + test "template_source with locals of strings" do + inst = SourceGeneratingMockTemplate.new { |t| 'Hey #{name}!' } + assert_equal "Hey Joe!", inst.render(Object.new, 'name' => 'Joe', :name=>'Joe') + assert inst.prepared? + end + test "template_source with locals having non-variable keys raises error" do inst = SourceGeneratingMockTemplate.new { |t| '1 + 2 = #{_answer}' } err = assert_raises(RuntimeError) { inst.render(Object.new, 'ANSWER' => 3) } diff -Nru ruby-tilt-2.0.1/test/tilt_typescript_test.rb ruby-tilt-2.0.8/test/tilt_typescript_test.rb --- ruby-tilt-2.0.1/test/tilt_typescript_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_typescript_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -0,0 +1,38 @@ +require 'test_helper' +require 'tilt' + +begin + require 'tilt/typescript' + + class TypeScriptTemplateTest < Minitest::Test + def setup + @ts = "var x:number = 5" + @js = /var x = 5;\s*/ + end + + test "is registered for '.ts' files" do + assert_equal Tilt::TypeScriptTemplate, Tilt['test.ts'] + end + + test "is registered for '.tsx' files" do + assert_equal Tilt::TypeScriptTemplate, Tilt['test.tsx'] + end + + test "compiles and evaluates the template on #render" do + template = Tilt::TypeScriptTemplate.new { @ts } + assert_match @js, template.render + end + + test "supports source map" do + template = Tilt::TypeScriptTemplate.new(inlineSourceMap: true) { @ts } + assert_match %r(sourceMappingURL), template.render + end + + test "can be rendered more than once" do + template = Tilt::TypeScriptTemplate.new { @ts } + 3.times { assert_match @js, template.render } + end + end +rescue LoadError + warn "Tilt::TypeScriptTemplate (disabled)" +end diff -Nru ruby-tilt-2.0.1/test/tilt_wikiclothtemplate_test.rb ruby-tilt-2.0.8/test/tilt_wikiclothtemplate_test.rb --- ruby-tilt-2.0.1/test/tilt_wikiclothtemplate_test.rb 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/test/tilt_wikiclothtemplate_test.rb 2017-08-18 22:03:01.000000000 +0000 @@ -19,14 +19,14 @@ test "compiles and evaluates the template on #render" do template = Tilt::WikiClothTemplate.new { |t| "= Hello World! =" } - assert_match /

.*Hello World!.*<\/h1>/, template.render + assert_match(/

.*Hello World!.*<\/h1>/m, template.render) end test "can be rendered more than once" do template = Tilt::WikiClothTemplate.new { |t| "= Hello World! =" } - 3.times { assert_match /

.*Hello World!.*<\/h1>/, template.render } + 3.times { assert_match(/

.*Hello World!.*<\/h1>/m, template.render) } end end -rescue LoadError => boom +rescue LoadError warn "Tilt::WikiClothTemplate (disabled)" end diff -Nru ruby-tilt-2.0.1/tilt.gemspec ruby-tilt-2.0.8/tilt.gemspec --- ruby-tilt-2.0.1/tilt.gemspec 2014-04-13 21:18:29.000000000 +0000 +++ ruby-tilt-2.0.8/tilt.gemspec 2017-08-18 22:03:01.000000000 +0000 @@ -3,8 +3,8 @@ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.name = 'tilt' - s.version = '2.0.1' - s.date = '2014-03-21' + s.version = '2.0.8' + s.date = '2017-07-24' s.description = "Generic interface to multiple Ruby template engines" s.summary = s.description @@ -26,71 +26,94 @@ docs/common.css lib/tilt.rb lib/tilt/asciidoc.rb + lib/tilt/babel.rb lib/tilt/bluecloth.rb lib/tilt/builder.rb lib/tilt/coffee.rb + lib/tilt/commonmarker.rb lib/tilt/creole.rb lib/tilt/csv.rb + lib/tilt/dummy.rb lib/tilt/erb.rb + lib/tilt/erubi.rb lib/tilt/erubis.rb lib/tilt/etanni.rb lib/tilt/haml.rb lib/tilt/kramdown.rb lib/tilt/less.rb lib/tilt/liquid.rb + lib/tilt/livescript.rb lib/tilt/mapping.rb lib/tilt/markaby.rb lib/tilt/maruku.rb lib/tilt/nokogiri.rb + lib/tilt/pandoc.rb lib/tilt/plain.rb + lib/tilt/prawn.rb lib/tilt/radius.rb lib/tilt/rdiscount.rb lib/tilt/rdoc.rb lib/tilt/redcarpet.rb lib/tilt/redcloth.rb + lib/tilt/rst-pandoc.rb lib/tilt/sass.rb + lib/tilt/sigil.rb lib/tilt/string.rb lib/tilt/template.rb + lib/tilt/typescript.rb lib/tilt/wikicloth.rb lib/tilt/yajl.rb + man/index.txt + man/tilt.1.ronn test/markaby/locals.mab test/markaby/markaby.mab test/markaby/markaby_other_static.mab test/markaby/render_twice.mab test/markaby/scope.mab test/markaby/yielding.mab + test/mytemplate.rb test/test_helper.rb test/tilt_asciidoctor_test.rb + test/tilt_babeltemplate.rb test/tilt_blueclothtemplate_test.rb test/tilt_buildertemplate_test.rb test/tilt_cache_test.rb test/tilt_coffeescripttemplate_test.rb + test/tilt_commonmarkertemplate_test.rb test/tilt_compilesite_test.rb test/tilt_creoletemplate_test.rb test/tilt_csv_test.rb test/tilt_erbtemplate_test.rb test/tilt_erubistemplate_test.rb + test/tilt_erubitemplate_test.rb test/tilt_etannitemplate_test.rb test/tilt_hamltemplate_test.rb test/tilt_kramdown_test.rb test/tilt_lesstemplate_test.less test/tilt_lesstemplate_test.rb test/tilt_liquidtemplate_test.rb + test/tilt_livescripttemplate_test.rb test/tilt_mapping_test.rb test/tilt_markaby_test.rb test/tilt_markdown_test.rb test/tilt_marukutemplate_test.rb test/tilt_metadata_test.rb test/tilt_nokogiritemplate_test.rb + test/tilt_pandoctemplate_test.rb + test/tilt_prawntemplate.prawn + test/tilt_prawntemplate_test.rb test/tilt_radiustemplate_test.rb test/tilt_rdiscounttemplate_test.rb test/tilt_rdoctemplate_test.rb test/tilt_redcarpettemplate_test.rb test/tilt_redclothtemplate_test.rb + test/tilt_rstpandoctemplate_test.rb test/tilt_sasstemplate_test.rb + test/tilt_sigil_test.rb test/tilt_stringtemplate_test.rb test/tilt_template_test.rb test/tilt_test.rb + test/tilt_typescript_test.rb test/tilt_wikiclothtemplate_test.rb test/tilt_yajltemplate_test.rb tilt.gemspec