From 5dc13d11bdb11d669d160e5d2df9f3797015a6f6 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 17 Dec 2024 20:57:59 -0800 Subject: [PATCH] Remove deprecated erubis, wikicloth, and maruku templates These all require modifying frozen string literals, so they would start raising deprecation warnings in Ruby 3.4. Tilt support for these templates has been deprecated for almost 6 months without complaint. --- .ci.gemfile | 12 --- .github/workflows/ci.yml | 3 +- CHANGELOG.md | 1 + README.md | 5 +- docs/TEMPLATES.md | 67 ++----------- lib/tilt.rb | 3 - lib/tilt/erubis.rb | 51 ---------- lib/tilt/mapping.rb | 6 +- lib/tilt/maruku.rb | 10 -- lib/tilt/wikicloth.rb | 12 --- test/test_helper.rb | 2 +- test/tilt_erubistemplate_test.rb | 146 ---------------------------- test/tilt_erubitemplate_test.rb | 17 ++-- test/tilt_markdown_test.rb | 17 ---- test/tilt_marukutemplate_test.rb | 35 ------- test/tilt_rdiscounttemplate_test.rb | 8 +- test/tilt_redcarpettemplate_test.rb | 8 +- test/tilt_wikiclothtemplate_test.rb | 26 ----- 18 files changed, 31 insertions(+), 398 deletions(-) delete mode 100644 lib/tilt/erubis.rb delete mode 100644 lib/tilt/maruku.rb delete mode 100644 lib/tilt/wikicloth.rb delete mode 100644 test/tilt_erubistemplate_test.rb delete mode 100644 test/tilt_marukutemplate_test.rb delete mode 100644 test/tilt_wikiclothtemplate_test.rb diff --git a/.ci.gemfile b/.ci.gemfile index af06ddf..2298a49 100644 --- a/.ci.gemfile +++ b/.ci.gemfile @@ -6,7 +6,6 @@ gem 'minitest' gem 'babel-transpiler' gem 'creole' gem 'erubi' -gem 'erubis' gem 'liquid' gem 'livescript' gem 'nokogiri' @@ -51,10 +50,6 @@ unless RUBY_VERSION < '2.4' && RUBY_ENGINE == 'jruby' gem 'pandoc-ruby' end -unless RUBY_VERSION < '2.6' && RUBY_ENGINE == 'jruby' - gem 'maruku' -end - if RUBY_ENGINE == 'jruby' gem 'haml', '< 6' else @@ -78,9 +73,6 @@ if RUBY_VERSION >= '3.1' end platform :ruby do - gem 'wikicloth' - gem 'rinku' # dependency for wikicloth for handling links - gem 'RedCloth' gem 'commonmarker' @@ -93,9 +85,5 @@ platform :ruby do # a dependency on ruby-enum, which requires Ruby 2.3 # without specifying required_ruby_version gem 'ruby-enum', '< 0.6' - - # i18n is pulled in by wikicloth. This avoids errors - # on Ruby 2.0. - gem 'i18n', '<1.3' end end diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcaa7e0..51f9c6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,9 +23,8 @@ jobs: COFFEE_SCRIPT: use steps: - uses: actions/checkout@v4 - # WikiCloth needs IDN # Pandoc needs Pandoc - - run: sudo apt-get install -y libidn11-dev pandoc + - run: sudo apt-get install -y pandoc - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} diff --git a/CHANGELOG.md b/CHANGELOG.md index ed2e892..3071a43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## master +* Remove deprecated erubis, wikicloth, and maruku templates (jeremyevans) * Avoid spurious frozen string literal deprecation warning on Ruby 3.4.0-preview2+ (jeremyevans) ## 2.4.0 (2024-06-27) diff --git a/README.md b/README.md index d24a408..3d0831f 100644 --- a/README.md +++ b/README.md @@ -33,14 +33,12 @@ Support for these template engines is included with Tilt: | CSV | .rcsv | csv (ruby stdlib) | | ERB | .erb, .rhtml | erb (ruby stdlib) | | Erubi | .erb, .rhtml, .erubi | erubi | -| Erubis | .erb, .rhtml, .erubis | erubis | | Etanni | .ern, .etanni | none | | Haml | .haml | haml | | Kramdown | .markdown, .mkd, .md | kramdown | | Liquid | .liquid | liquid | | LiveScript | .ls | livescript (+ javascript) | | Markaby | .mab | markaby | -| Maruku | .markdown, .mkd, .md | maruku | | Nokogiri | .nokogiri | nokogiri | | Pandoc | .markdown, .mkd, .md | pandoc | | Plain | .html | none | @@ -56,7 +54,6 @@ Support for these template engines is included with Tilt: | Scss | .scss | sass-embedded, sassc, or sass | | String | .str | none | | TypeScript | .ts | typescript (+ javascript) | -| WikiCloth | .wiki, .mediawiki, .mw | wikicloth | | Yajl | .yajl | yajl-ruby | See [TEMPLATES.md][t] for detailed information on template engine @@ -277,7 +274,7 @@ it on subsequent template invocations. Benchmarks show this yields a 5x-10x performance increase over evaluating the Ruby source on each invocation. Template compilation is currently supported for these template engines: -StringTemplate, ERB, Erubis, Erubi, Etanni, Haml, Nokogiri, Builder, CSV, +StringTemplate, ERB, Erubi, Etanni, Haml, Nokogiri, Builder, CSV, Prawn, and Yajl. LICENSE diff --git a/docs/TEMPLATES.md b/docs/TEMPLATES.md index 0c67e1c..64805a1 100644 --- a/docs/TEMPLATES.md +++ b/docs/TEMPLATES.md @@ -11,9 +11,8 @@ which are guaranteed to work across all the implementations. If you wish to be compatible with all of these template classes, you should only depend on the cross-implementation features. - * [ERB](#erb) - Generic ERB implementation (backed by erb.rb, Erubis, or Erubi) + * [ERB](#erb) - Generic ERB implementation (backed by erb.rb or Erubi) * [erb.rb](#erbrb) - `Tilt::ERBTemplate` - * [Erubis](#erubis) - `Tilt::ErubisTemplate` * [Erubi](#erubi) - `Tilt::ErubiTemplate` * [Haml](#haml) - `Tilt::HamlTemplate` * [Liquid](#liquid) - `Tilt::LiquidTemplate` @@ -44,7 +43,6 @@ implementations (depending on which are available on your system): * Kramdown - `Tilt::KramdownTemplate` * Pandoc - `Tilt::PandocTemplate` * CommonMarker - `Tilt::CommonMarkerTemplate` - * Maruku - `Tilt::MarukuTemplate` ERB (`erb`, `rhtml`) @@ -52,7 +50,7 @@ ERB (`erb`, `rhtml`) ERB is a simple but powerful template languge for Ruby. In Tilt it's backed by [Erubi](#erubi) (if installed on your system) or by -[Erubis](#erubis) (if installed on your system) or by [erb.rb](#erbrb) (which +[erb.rb](#erbrb) (which is included in Ruby's standard library). This documentation applies to all three implementations. @@ -81,7 +79,7 @@ Or, use `Tilt['erb']` directly to process strings: Omits newlines and spaces around certain lines (usually those that starts with `<%` and ends with `%>`). There isn't a specification for how trimming in ERB should work, so if you need more control over the whitespace, you should use -[erb.rb](#erbrb), [Erubis](#erubis), or [Erubi](#erubi) directly. +[erb.rb](#erbrb) or [Erubi](#erubi) directly. #### `:outvar => '_erbout'` @@ -106,8 +104,8 @@ All the documentation of [ERB](#erb) applies in addition to the following: ### Usage The `Tilt::ERBTemplate` class is registered for all files ending in `.erb` or -`.rhtml` by default, but with a *lower* priority than ErubiTemplate and -ErubisTemplate. If you specifically want to use ERB, it's recommended to use +`.rhtml` by default, but with a *lower* priority than ErubiTemplate. +If you specifically want to use ERB, it's recommended to use `#prefer`: Tilt.prefer Tilt::ERBTemplate @@ -132,53 +130,12 @@ following characters: * [ERB documentation](https://docs.ruby-lang.org/en/master/ERB.html) - -Erubis (`erb`, `rhtml`, `erubis`) ---------------------------------- - -[Erubis][erubis] is a fast, secure, and very extensible implementation of [ERB](#erb). - -All the documentation of [ERB](#erb) applies in addition to the following: - -### Usage - -The `Tilt::ErubisTemplate` class is registered for all files ending in `.erb` or -`.rhtml` by default, but with a *lower* priority than `ErubiTemplate`. If you -specifically want to use Erubis, it's recommended to use `#prefer`: - - Tilt.prefer Tilt::ErubisTemplate - -__NOTE:__ It's suggested that your program `require 'erubis'` at load time when -using this template engine within a threaded environment. - -### Options - -#### `:engine_class => Erubis::Eruby` - -Allows you to specify a custom engine class to use instead of the -default which is `Erubis::Eruby`. - -#### `:escape_html => false` - -When `true`, `Erubis::EscapedEruby` will be used as the engine class -instead of the default. All content within `<%= %>` blocks will be -automatically html escaped. - -#### Other - -Other options are passed to the constructor of the engine class. - -### See also - - * [Erubis Home][erubis] - - Erubi (`erb`, `rhtml`, `erubi`) --------------------------------- -[Erubi][erubi] is a ERB implementation that uses the same algorithm as -[Erubis][erubis], but is maintained and offers numerous improvements.. +[Erubi][erubi] is an ERB implementation that uses the same algorithm as +the erubis gem, but is maintained and offers numerous improvements. All the documentation of [ERB](#erb) applies in addition to the following: @@ -187,8 +144,6 @@ All the documentation of [ERB](#erb) applies in addition to the following: The `Tilt::ErubiTemplate` class is registered for all files ending in `.erb` or `.rhtml` by default, with the *highest* priority. - Tilt.prefer Tilt::ErubisTemplate - __NOTE:__ It's suggested that your program `require 'erubi'` at load time when using this template engine within a threaded environment. @@ -477,7 +432,6 @@ Markdown formatted texts are converted to HTML with one of these libraries: * Redcarpet - `Tilt::RedcarpetTemplate` * Kramdown - `Tilt::KramdownTemplate` * Pandoc - `Tilt::PandocTemplate` - * Maruku - `Tilt::MarukuTemplate` * CommonMarker - `Tilt::CommonMarkerTemplate` ### Example @@ -501,7 +455,7 @@ To wrap a Markdown formatted document with a layout: ### 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 engine. #### `:smartypants => true|false` @@ -510,14 +464,12 @@ Set `true` to enable [Smarty Pants][smartypants] style punctuation replacement. In Kramdown this option only applies to smart quotes. It will apply a subset of Smarty Pants (e.g. `...` to `…`) regardless of any option. -Maruku ignores this option and always applies smart quotes (and nothing else). - #### `:escape_html => true|false` Set `true` disallow raw HTML in Markdown contents. HTML is converted to literal text by escaping `<` characters. -Kramdown and Maruku don't support this option. +Kramdown doesn't support this option. ### See also @@ -552,7 +504,6 @@ using this template engine within a threaded environment. [sass]: http://sass-lang.com/ "Sass" [coffee-script]: http://jashkenas.github.com/coffee-script/ "Coffee Script" -[erubis]: https://github.com/kwatch/erubis "Erubis" [erubi]: https://github.com/jeremyevans/erubi "Erubi" [haml]: http://haml.info/ "Haml" [liquid]: http://www.liquidmarkup.org/ "Liquid" diff --git a/lib/tilt.rb b/lib/tilt.rb index 1bc112b..c65cc4a 100644 --- a/lib/tilt.rb +++ b/lib/tilt.rb @@ -139,11 +139,9 @@ def clear # 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 :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' @@ -175,7 +173,6 @@ def clear register_lazy :SlimTemplate, 'tilt/slim', 'slim' 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' # TILT3: Remove diff --git a/lib/tilt/erubis.rb b/lib/tilt/erubis.rb deleted file mode 100644 index f85cc25..0000000 --- a/lib/tilt/erubis.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true -require_relative 'erb' -require 'erubis' - -warn 'tilt/erubis is deprecated, as erubis requires modifying string literals', uplevel: 1 - -module Tilt - # Erubis template implementation. See: - # http://www.kuwata-lab.com/erubis/ - # - # ErubisTemplate supports the following additional options, which are not - # passed down to the Erubis engine: - # - # :engine_class allows you to specify a custom engine class to use - # instead of the default (which is ::Erubis::Eruby). - # - # :escape_html when true, ::Erubis::EscapedEruby will be used as - # the engine class instead of the default. All content - # within <%= %> blocks will be automatically html escaped. - class ErubisTemplate < ERBTemplate - def prepare - @freeze_string_literals = !!@options.delete(:freeze) - @outvar = @options.delete(:outvar) || '_erbout' - @options[:preamble] = false - @options[:postamble] = false - @options[:bufvar] = @outvar - engine_class = @options.delete(:engine_class) - engine_class = ::Erubis::EscapedEruby if @options.delete(:escape_html) - @engine = (engine_class || ::Erubis::Eruby).new(@data, @options) - end - - def precompiled_preamble(locals) - [super, "#{@outvar} = _buf = String.new"].join("\n") - end - - def precompiled_postamble(locals) - [@outvar, super].join("\n") - end - - # Erubis doesn't have ERB's line-off-by-one under 1.9 problem. - # Override and adjust back. - def precompiled(locals) - source, offset = super - [source, offset - 1] - end - - def freeze_string_literals? - @freeze_string_literals - end - end -end diff --git a/lib/tilt/mapping.rb b/lib/tilt/mapping.rb index 53c0cc5..a4cb3b3 100644 --- a/lib/tilt/mapping.rb +++ b/lib/tilt/mapping.rb @@ -113,14 +113,14 @@ def split(file) # the exception of the first, since that was the most preferred one. # # mapping = Tilt::Mapping.new - # mapping.register_lazy('Maruku::Template', 'maruku/template', 'md') + # mapping.register_lazy('Kramdown::Template', 'kramdown/template', 'md') # mapping.register_lazy('RDiscount::Template', 'rdiscount/template', 'md') # mapping['index.md'] # # => RDiscount::Template # # In the previous example we say that RDiscount has a *higher priority* than - # Maruku. Tilt will first try to `require "rdiscount/template"`, falling - # back to `require "maruku/template"`. If none of these are successful, + # Kramdown. Tilt will first try to `require "rdiscount/template"`, falling + # back to `require "kramdown/template"`. If none of these are successful, # the first error will be raised. class Mapping < BaseMapping LOCK = Mutex.new diff --git a/lib/tilt/maruku.rb b/lib/tilt/maruku.rb deleted file mode 100644 index 7c42e64..0000000 --- a/lib/tilt/maruku.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true -require_relative 'template' -require 'maruku' - -warn 'tilt/maruku is deprecated, as maruku requires modifying string literals', uplevel: 1 - -# Maruku markdown implementation. See: https://github.com/bhollis/maruku -Tilt::MarukuTemplate = Tilt::StaticTemplate.subclass do - Maruku.new(@data, @options).to_html -end diff --git a/lib/tilt/wikicloth.rb b/lib/tilt/wikicloth.rb deleted file mode 100644 index c5c9988..0000000 --- a/lib/tilt/wikicloth.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true -require_relative 'template' -require 'wikicloth' - -warn 'tilt/wikicloth is deprecated, as wikicloth requires modifying string literals', uplevel: 1 - -# WikiCloth implementation. See: https://github.com/nricciar/wikicloth -Tilt::WikiClothTemplate = Tilt::StaticTemplate.subclass do - parser = @options.delete(:parser) || WikiCloth::Parser - @options[:data] = @data - parser.new(@options).to_html -end diff --git a/test/test_helper.rb b/test/test_helper.rb index c2f9210..3b062d8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -13,7 +13,7 @@ require 'warning' rescue LoadError else - Warning.ignore(%r{lib/wikicloth/extensions/|lib/pdf/reader/font.rb|lib/maruku/|lib/creole/parser.rb|lib/commonmarker}) + Warning.ignore(%r{lib/pdf/reader/font.rb|lib/creole/parser.rb|lib/commonmarker}) end end diff --git a/test/tilt_erubistemplate_test.rb b/test/tilt_erubistemplate_test.rb deleted file mode 100644 index b534074..0000000 --- a/test/tilt_erubistemplate_test.rb +++ /dev/null @@ -1,146 +0,0 @@ -require_relative 'test_helper' - -checked_describe 'tilt/erubis' do - include IgnoreVerboseWarnings - - data = (< - -

Hey <%= name %>!

- - -

<% fail %>

- - -END - - it "registered for '.erubis' files" do - assert_equal Tilt::ErubisTemplate, Tilt['test.erubis'] - assert_equal Tilt::ErubisTemplate, Tilt['test.html.erubis'] - end - - it "registered above ERB" do - %w[erb rhtml].each do |ext| - lazy = Tilt.lazy_map[ext] - erubis_idx = lazy.index { |klass, file| klass == 'Tilt::ErubisTemplate' } - erb_idx = lazy.index { |klass, file| klass == 'Tilt::ERBTemplate' } - assert erubis_idx < erb_idx, - "#{erubis_idx} should be lower than #{erb_idx}" - end - end - - it "preparing and evaluating templates on #render" do - template = Tilt::ErubisTemplate.new { |t| "Hello World!" } - assert_equal "Hello World!", template.render - end - - it "can be rendered more than once" do - template = Tilt::ErubisTemplate.new { |t| "Hello World!" } - 3.times { assert_equal "Hello World!", template.render } - end - - it "passing locals" do - template = Tilt::ErubisTemplate.new { 'Hey <%= name %>!' } - assert_equal "Hey Joe!", template.render(Object.new, :name => 'Joe') - end - - it "evaluating in an object scope" do - template = Tilt::ErubisTemplate.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 - - it "exposing the buffer to the template by default" do - template = Tilt::ErubisTemplate.new(:outvar=>'@_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 - - it "passing a block for yield" do - template = Tilt::ErubisTemplate.new { 'Hey <%= yield %>!' } - assert_equal "Hey Joe!", template.render { 'Joe' } - end - - it "backtrace file and line reporting without locals" do - template = Tilt::ErubisTemplate.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(/\Atest\.erubis:/).first - assert line, "Backtrace didn't contain test.erubis" - _file, line, _meth = line.split(":") - assert_equal '13', line - end - end - - it "backtrace file and line reporting with locals" do - template = Tilt::ErubisTemplate.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 - - it "erubis template options" do - template = Tilt::ErubisTemplate.new(nil, :pattern => '\{% %\}') { 'Hey {%= @name %}!' } - scope = Object.new - scope.instance_variable_set :@name, 'Joe' - assert_equal "Hey Joe!", template.render(scope) - end - - it "using an instance variable as the outvar" do - template = Tilt::ErubisTemplate.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 - - it "using Erubis::EscapedEruby subclass via :engine_class option" do - template = Tilt::ErubisTemplate.new(nil, :engine_class => ::Erubis::EscapedEruby) { |t| %(<%= "

Hello World!

" %>) } - assert_equal "<p>Hello World!</p>", template.render - end - - it "using :escape_html => true option" do - template = Tilt::ErubisTemplate.new(nil, :escape_html => true) { |t| %(<%= "

Hello World!

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

Hello World!

" %>) } - assert_equal "

Hello World!

", template.render - end - - it "erubis default does not escape html" do - template = Tilt::ErubisTemplate.new { |t| %(<%= "

Hello World!

" %>) } - assert_equal "

Hello World!

", template.render - end - - it "does not modify options argument" do - options_hash = {:escape_html => true} - Tilt::ErubisTemplate.new(nil, options_hash) { |t| "Hello World!" } - assert_equal({:escape_html => true}, options_hash) - end - - if RUBY_VERSION >= '2.3' - it "uses frozen literal strings if :freeze option is used" do - template = Tilt::ErubisTemplate.new(nil, :freeze => true) { |t| %(<%= "".frozen? %>) } - assert_equal "true", template.render - end - end -end diff --git a/test/tilt_erubitemplate_test.rb b/test/tilt_erubitemplate_test.rb index 641775a..437c469 100644 --- a/test/tilt_erubitemplate_test.rb +++ b/test/tilt_erubitemplate_test.rb @@ -17,14 +17,11 @@ assert_equal Tilt::ErubiTemplate, Tilt['test.html.erubi'] end - it "registered above ERB and Erubis" do + it "registered above ERB" 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 @@ -69,21 +66,21 @@ end it "backtrace file and line reporting without locals" do - template = Tilt::ErubiTemplate.new('test.erubis', 11) { data } + template = Tilt::ErubiTemplate.new('test.erubi', 11) { data } begin template.render fail 'should have raised an exception' rescue => boom assert_kind_of NameError, boom - line = boom.backtrace.grep(/\Atest\.erubis:/).first - assert line, "Backtrace didn't contain test.erubis" + line = boom.backtrace.grep(/\Atest\.erubi:/).first + assert line, "Backtrace didn't contain test.erubi" _file, line, _meth = line.split(":") assert_equal '13', line end end it "backtrace file and line reporting with locals" do - template = Tilt::ErubiTemplate.new('test.erubis', 1) { data } + template = Tilt::ErubiTemplate.new('test.erubi', 1) { data } begin template.render(nil, :name => 'Joe', :foo => 'bar') fail 'should have raised an exception' @@ -91,12 +88,12 @@ assert_kind_of RuntimeError, boom line = boom.backtrace.first file, line, _meth = line.split(":") - assert_equal 'test.erubis', file + assert_equal 'test.erubi', file assert_equal '6', line end end - it "erubis template options" do + it "erubi template options" do template = Tilt::ErubiTemplate.new(nil, :escapefunc=> 'h') { 'Hey <%== @name %>!' } scope = Object.new def scope.h(s) s * 2 end diff --git a/test/tilt_markdown_test.rb b/test/tilt_markdown_test.rb index cf54bec..a7d8936 100644 --- a/test/tilt_markdown_test.rb +++ b/test/tilt_markdown_test.rb @@ -130,22 +130,5 @@ def nrender(text, options = {}) end end -checked_require('tilt/maruku') do - markdown_describe.call 'tilt/maruku', :MarukuTemplate do - include IgnoreVerboseWarnings - - skip_tests = [ - ':escape_html => true', - 'smartypants by default', - 'smartypants if :smartypants => false', - 'smart quotes by default', - 'smart quotes if :smartypants => false', - ] - instance_methods.grep(/#{Regexp.union(skip_tests)}\z/).each do |method| - undef_method method - end - end -end - markdown_describe.call 'tilt/pandoc', :PandocTemplate end diff --git a/test/tilt_marukutemplate_test.rb b/test/tilt_marukutemplate_test.rb deleted file mode 100644 index 6688d6f..0000000 --- a/test/tilt_marukutemplate_test.rb +++ /dev/null @@ -1,35 +0,0 @@ -require_relative 'test_helper' - -checked_describe 'tilt/maruku' do - include IgnoreVerboseWarnings - - it "registered below Kramdown" do - %w[md mkd markdown].each do |ext| - lazy = Tilt.lazy_map[ext] - kram_idx = lazy.index { |klass, file| klass == 'Tilt::KramdownTemplate' } - maru_idx = lazy.index { |klass, file| klass == 'Tilt::MarukuTemplate' } - assert maru_idx > kram_idx, - "#{maru_idx} should be higher than #{kram_idx}" - end - end - - it "preparing and evaluating templates on #render" do - template = Tilt::MarukuTemplate.new { |t| "# Hello World!" } - assert_equal "

Hello World!

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

Hello World!

", template.render.strip } - end - - it "removes HTML when :filter_html is set" do - template = Tilt::MarukuTemplate.new(:filter_html => true) { |t| - "HELLO WORLD" } - assert_equal "

HELLO

", template.render.strip - end - - it "sets allows_script metadata set to false" do - assert_equal false, Tilt::MarukuTemplate.new { |t| "# Hello World!" }.metadata[:allows_script] - end -end diff --git a/test/tilt_rdiscounttemplate_test.rb b/test/tilt_rdiscounttemplate_test.rb index 5d27fa6..0be04f4 100644 --- a/test/tilt_rdiscounttemplate_test.rb +++ b/test/tilt_rdiscounttemplate_test.rb @@ -1,13 +1,13 @@ require_relative 'test_helper' checked_describe 'tilt/rdiscount' do - it "registered above Maruku" do + it "registered above Kramdown" do %w[md mkd markdown].each do |ext| lazy = Tilt.lazy_map[ext] rdis_idx = lazy.index { |klass, file| klass == 'Tilt::RDiscountTemplate' } - maruku_idx = lazy.index { |klass, file| klass == 'Tilt::MarukuTemplate' } - assert rdis_idx < maruku_idx, - "#{rdis_idx} should be lower than #{maruku_idx}" + kd_idx = lazy.index { |klass, file| klass == 'Tilt::KramdownTemplate' } + assert rdis_idx < kd_idx, + "#{rdis_idx} should be lower than #{kd_idx}" end end diff --git a/test/tilt_redcarpettemplate_test.rb b/test/tilt_redcarpettemplate_test.rb index 32c2119..d1930b2 100644 --- a/test/tilt_redcarpettemplate_test.rb +++ b/test/tilt_redcarpettemplate_test.rb @@ -6,13 +6,13 @@ assert_equal ['markdown', 'mkd', 'md'], extensions end - it "registered above Maruku" do + it "registered above Kramdown" do %w[md mkd markdown].each do |ext| lazy = Tilt.lazy_map[ext] - maruku_idx = lazy.index { |klass, file| klass == 'Tilt::MarukuTemplate' } + kd_idx = lazy.index { |klass, file| klass == 'Tilt::KramdownTemplate' } redc_idx = lazy.index { |klass, file| klass == 'Tilt::RedcarpetTemplate' } - assert redc_idx < maruku_idx, - "#{redc_idx} should be lower than #{maruku_idx}" + assert redc_idx < kd_idx, + "#{redc_idx} should be lower than #{kd_idx}" end end diff --git a/test/tilt_wikiclothtemplate_test.rb b/test/tilt_wikiclothtemplate_test.rb deleted file mode 100644 index 2879d1d..0000000 --- a/test/tilt_wikiclothtemplate_test.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative 'test_helper' - -checked_describe 'tilt/wikicloth' do - include IgnoreVerboseWarnings - - it "is registered for '.mediawiki' files" do - assert_equal Tilt::WikiClothTemplate, Tilt['test.mediawiki'] - end - - it "is registered for '.mw' files" do - assert_equal Tilt::WikiClothTemplate, Tilt['test.mw'] - end - - it "is registered for '.wiki' files" do - assert_equal Tilt::WikiClothTemplate, Tilt['test.wiki'] - end - - it "can be rendered more than once" do - template = Tilt::WikiClothTemplate.new { |t| "= Hello World! =" } - 3.times { assert_match(/

.*Hello World!.*<\/h1>/m, template.render) } - end - - it "sets allows_script metadata set to false" do - assert_equal false, Tilt::WikiClothTemplate.new { |t| "= Hello World! =" }.metadata[:allows_script] - end -end