19070: Still trying to fix test_with_arvbox
[arvados.git] / doc / zenweb-liquid.rb
index baa8fe42db39ddbcd320c9b0cae48ac06bb301f3..3e8672e0216e0290982556b82f83eac964a34534 100644 (file)
@@ -50,7 +50,7 @@ module Zenweb
       Liquid::Tag.instance_method(:initialize).bind(self).call(tag_name, markup, tokens)
 
       if markup =~ Syntax
-        @template_name = $1
+        @template_name_expr = $1
         @language = $3
         @attributes    = {}
       else
@@ -61,9 +61,14 @@ module Zenweb
     def render(context)
       require 'coderay'
 
-      partial = load_cached_partial(context)
+      partial = load_cached_partial(@template_name_expr, context)
       html = ''
 
+      # be explicit about errors
+      context.exception_renderer = lambda do |exc|
+        exc.is_a?(Liquid::InternalError) ? "Liquid error: #{exc.cause.message}" : exc
+      end
+
       context.stack do
         html = CodeRay.scan(partial.root.nodelist.join, @language).div
       end
@@ -98,6 +103,11 @@ module Zenweb
         partial = partial[1..-1]
       end
 
+      # be explicit about errors
+      context.exception_renderer = lambda do |exc|
+        exc.is_a?(Liquid::InternalError) ? "Liquid error: #{exc.cause.message}" : exc
+      end
+
       context.stack do
         html = CodeRay.scan(partial, @language).div
       end