mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Move localization option to register
This commit is contained in:
@@ -61,8 +61,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
# creates a new <tt>Template</tt> from an array of tokens. Use <tt>Template.parse</tt> instead
|
# creates a new <tt>Template</tt> from an array of tokens. Use <tt>Template.parse</tt> instead
|
||||||
def initialize(options = {})
|
def initialize
|
||||||
registers[:locale] = I18n.new(options[:locale]) || I18n.new
|
|
||||||
@resource_limits = {}
|
@resource_limits = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -80,7 +79,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def registers
|
def registers
|
||||||
@registers ||= {}
|
@registers ||= {:locale => Liquid::I18n.new}
|
||||||
end
|
end
|
||||||
|
|
||||||
def assigns
|
def assigns
|
||||||
|
|||||||
@@ -145,14 +145,14 @@ class TemplateTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_sets_default_localization_in_context
|
def test_sets_default_localization_in_context
|
||||||
t = Template.new(:locale => fixture("en_locale.yml"))
|
t = Template.new
|
||||||
|
|
||||||
assert_instance_of I18n, t.registers[:locale]
|
assert_instance_of I18n, t.registers[:locale]
|
||||||
assert_equal fixture("en_locale.yml"), t.registers[:locale].path
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sets_default_localization_in_context_with_quick_initialization
|
def test_sets_default_localization_in_context_with_quick_initialization
|
||||||
t = Template.parse('{{foo}}', :locale => fixture("en_locale.yml"))
|
t = Template.new
|
||||||
|
t.registers[:locale] = I18n.new(fixture("en_locale.yml"))
|
||||||
|
t.parse('{{foo}}')
|
||||||
|
|
||||||
assert_instance_of I18n, t.registers[:locale]
|
assert_instance_of I18n, t.registers[:locale]
|
||||||
assert_equal fixture("en_locale.yml"), t.registers[:locale].path
|
assert_equal fixture("en_locale.yml"), t.registers[:locale].path
|
||||||
|
|||||||
Reference in New Issue
Block a user