require 'helper' require 'slim/translator' class TestSlimTranslator < TestSlim def setup super Slim::Engine.set_default_options :tr => true, :tr_fn => 'TestSlimTranslator.tr' end def self.tr(s) s.upcase end def self.tr_reverse(s) s.reverse.gsub(/(\d+)%/, '%\1') end def test_no_translation_of_embedded source = %q{ markdown: #Header Hello from #{"Markdown!"} #{1+2} * one * two } assert_html "
Hello from Markdown!
\n\n3
\n\nHello from Markdown!
\n\n3
\n\ntranslate Hello World from @env this\nsecond line\nthird 3 line
", source, :tr => false assert_html "TRANSLATE Hello World from @env THIS\nSECOND LINE\nTHIRD 3 LINE
", source, :tr_mode => :dynamic assert_html "TRANSLATE Hello World from @env THIS\nSECOND LINE\nTHIRD 3 LINE
", source, :tr_mode => :static end def test_translation_reverse source = %q{ ' alpha #{1} beta #{2} gamma #{3} } assert_html "3 ammag 2 ateb 1 ahpla ", source, :tr_mode => :dynamic, :tr_fn => 'TestSlimTranslator.tr_reverse' assert_html "3 ammag 2 ateb 1 ahpla ", source, :tr_mode => :static, :tr_fn => 'TestSlimTranslator.tr_reverse' end end