mirror of
https://github.com/kemko/liquid.git
synced 2026-01-02 08:15:41 +03:00
Compare commits
4 Commits
ragel_c
...
hotfix_bla
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9559d69e11 | ||
|
|
50bd34fd78 | ||
|
|
ee41b3f4a3 | ||
|
|
05d9976e16 |
@@ -20,9 +20,10 @@ module Liquid
|
||||
# Your drop can either implement the methods sans any parameters or implement the before_method(name) method which is a
|
||||
# catch all.
|
||||
class Drop
|
||||
attr_writer :context
|
||||
|
||||
EMPTY_STRING = ''.freeze
|
||||
METHOD_BLACKLIST = [:dup, :clone, :singleton_class, :eval, :class_eval, :`, :inspect]
|
||||
|
||||
attr_writer :context
|
||||
|
||||
# Catch all for the method
|
||||
def before_method(method)
|
||||
@@ -47,5 +48,9 @@ module Liquid
|
||||
end
|
||||
|
||||
alias :[] :invoke_drop
|
||||
|
||||
METHOD_BLACKLIST.each do |blacklisted|
|
||||
define_method(blacklisted) {nil}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ module Liquid
|
||||
# {{ user | link }}
|
||||
#
|
||||
class Variable
|
||||
FilterParser = /(?:#{FilterSeparator}|(?:\s*(?!(?:#{FilterSeparator}))(?:#{QuotedFragment}|\S+)\s*)+)/o
|
||||
FilterParser = /(?:#{FilterSeparator}|(?:\s*(?:#{QuotedFragment}|#{ArgumentSeparator})\s*)+)/o
|
||||
attr_accessor :filters, :name
|
||||
|
||||
def initialize(markup)
|
||||
|
||||
@@ -5,6 +5,7 @@ require File.dirname(__FILE__) + '/theme_runner'
|
||||
profiler = ThemeRunner.new
|
||||
|
||||
Benchmark.bmbm do |x|
|
||||
x.report("parse & run:") { 10.times { profiler.run(false) } }
|
||||
x.report("parse:") { 100.times { profiler.compile } }
|
||||
x.report("parse & run:") { 100.times { profiler.run } }
|
||||
end
|
||||
|
||||
|
||||
@@ -27,8 +27,33 @@ class ThemeRunner
|
||||
end.compact
|
||||
end
|
||||
|
||||
def compile
|
||||
# Dup assigns because will make some changes to them
|
||||
|
||||
def run()
|
||||
@tests.each do |liquid, layout, template_name|
|
||||
|
||||
tmpl = Liquid::Template.new
|
||||
tmpl.parse(liquid)
|
||||
tmpl = Liquid::Template.new
|
||||
tmpl.parse(layout)
|
||||
end
|
||||
end
|
||||
|
||||
def run
|
||||
# Dup assigns because will make some changes to them
|
||||
assigns = Database.tables.dup
|
||||
|
||||
@tests.each do |liquid, layout, template_name|
|
||||
|
||||
# Compute page_tempalte outside of profiler run, uninteresting to profiler
|
||||
page_template = File.basename(template_name, File.extname(template_name))
|
||||
compile_and_render(liquid, layout, assigns, page_template)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def run_profile
|
||||
RubyProf.measure_mode = RubyProf::WALL_TIME
|
||||
|
||||
# Dup assigns because will make some changes to them
|
||||
|
||||
@@ -66,6 +66,10 @@ class VariableTest < Test::Unit::TestCase
|
||||
var = Variable.new('hello|textileze|paragraph')
|
||||
assert_equal 'hello', var.name
|
||||
assert_equal [[:textileze,[]], [:paragraph,[]]], var.filters
|
||||
|
||||
var = Variable.new("hello|replace:'foo','bar'|textileze")
|
||||
assert_equal 'hello', var.name
|
||||
assert_equal [[:replace, ["'foo'", "'bar'"]], [:textileze, []]], var.filters
|
||||
end
|
||||
|
||||
def test_symbol
|
||||
|
||||
Reference in New Issue
Block a user