liquid-template-inheritance 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +27 -0
- data/Rakefile +29 -0
- data/lib/liquid-template-inheritance.rb +5 -0
- data/lib/liquid/template_inheritance/drops/inherited_block_drop.rb +26 -0
- data/lib/liquid/template_inheritance/i18n.rb +32 -0
- data/lib/liquid/template_inheritance/locales/en.yml +5 -0
- data/lib/liquid/template_inheritance/tags/extends.rb +79 -0
- data/lib/liquid/template_inheritance/tags/inherited_block.rb +94 -0
- data/lib/liquid/template_inheritance/version.rb +7 -0
- data/liquid-template-inheritance.gemspec +27 -0
- data/test/fixtures/en_locale.yml +9 -0
- data/test/integration/tags/extends_tag_test.rb +82 -0
- data/test/test_helper.rb +30 -0
- data/test/unit/i18n_unit_test.rb +22 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9130d16cdaf8ed2cb372346545efea5dbb35f685
|
4
|
+
data.tar.gz: bcf3e62f18f8566bb219c9d0740ec4de62980524
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 336c6800298678906606546c124976aee4a0e6824d3da719bcb67bfadf32a99b7811b5d6ab4c28f9ad45315658a2e51ce5111acb0936176837accadd5b7054ad
|
7
|
+
data.tar.gz: 6c0ddc5655035e1065e76783e0668ef5cb21e38d7fd9f5710c9dccb8c63967bee5121e1b3848a44b2e42b503b104b99b4984052c1396c23bb05afa86a8c5f781
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
Gemfile.lock
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
/.config
|
5
|
+
/coverage/
|
6
|
+
/InstalledFiles
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalisation:
|
25
|
+
/.bundle/
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 LocomotiveCMS
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Template inheritance add-on for Liquid
|
2
|
+
===
|
3
|
+
|
4
|
+
Implementation of template inheritance, similar to what offers [Django](https://docs.djangoproject.com/en/dev/topics/templates/).
|
5
|
+
|
6
|
+
See the discussion with the Shopify team about it [here](https://github.com/Shopify/liquid/pull/336).
|
7
|
+
|
8
|
+
**Important**. That's not a fork of the Liquid gem, it's rather a kind of add-on for Liquid. It requires a version of Liquid higher than the 3.0.0.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile, just after the one related to Liquid.
|
13
|
+
|
14
|
+
gem 'liquid-template-inheritance'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle install
|
19
|
+
|
20
|
+
## Contributing
|
21
|
+
|
22
|
+
1. Fork it ( http://github.com/<my-github-username>/locomotivecms/liquid-template-inheritance )
|
23
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
24
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
25
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
26
|
+
5. Create new Pull Request
|
27
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
require_relative "lib/liquid/template_inheritance/version"
|
5
|
+
|
6
|
+
task :default => 'test'
|
7
|
+
|
8
|
+
desc 'run test suite'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << '.' << 'lib' << 'test'
|
11
|
+
t.test_files = FileList['test/{integration,unit}/**/*_test.rb']
|
12
|
+
t.verbose = false
|
13
|
+
end
|
14
|
+
|
15
|
+
task :gem => :build
|
16
|
+
task :build do
|
17
|
+
system "gem build liquid-template-inheritance.gemspec"
|
18
|
+
end
|
19
|
+
|
20
|
+
task :install => :build do
|
21
|
+
system "gem install liquid-template-inheritance-#{Liquid::TemplateInheritance::VERSION}.gem"
|
22
|
+
end
|
23
|
+
|
24
|
+
task :release => :build do
|
25
|
+
system "git tag -a v#{Liquid::TemplateInheritance::VERSION} -m 'Tagging #{Liquid::TemplateInheritance::VERSION}'"
|
26
|
+
system "git push --tags"
|
27
|
+
system "gem push liquid-template-inheritance-#{Liquid::TemplateInheritance::VERSION}.gem"
|
28
|
+
system "rm liquid-template-inheritance-#{Liquid::TemplateInheritance::VERSION}.gem"
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Liquid
|
2
|
+
module TemplateInheritance
|
3
|
+
|
4
|
+
# Used to render the content of the parent block.
|
5
|
+
#
|
6
|
+
# {% extends home %}
|
7
|
+
# {% block content }{{ block.super }}{% endblock %}
|
8
|
+
#
|
9
|
+
class InheritedBlockDrop < Drop
|
10
|
+
|
11
|
+
def initialize(block)
|
12
|
+
@block = block
|
13
|
+
end
|
14
|
+
|
15
|
+
def name
|
16
|
+
@block.name
|
17
|
+
end
|
18
|
+
|
19
|
+
def super
|
20
|
+
@block.call_super(@context)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Liquid
|
2
|
+
class I18n
|
3
|
+
|
4
|
+
TEMPLATE_INHERITANCE_DEFAULT_LOCALE = File.join(File.expand_path(File.dirname(__FILE__)), "locales", "en.yml")
|
5
|
+
|
6
|
+
def locale_with_template_inheritance
|
7
|
+
if @path != DEFAULT_LOCALE
|
8
|
+
# we assume that the developers already included the keys concerning the template inheritance.
|
9
|
+
locale_without_template_inheritance
|
10
|
+
else
|
11
|
+
# memoization
|
12
|
+
return @locale if @locale
|
13
|
+
|
14
|
+
default = locale_without_template_inheritance
|
15
|
+
addon = YAML.load_file(TEMPLATE_INHERITANCE_DEFAULT_LOCALE)
|
16
|
+
|
17
|
+
deep_merge(addon, default)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
alias_method :locale_without_template_inheritance, :locale
|
22
|
+
alias_method :locale, :locale_with_template_inheritance
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def deep_merge(locale_1, locale_2)
|
27
|
+
merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? deep_merge(v1, v2) : v2 }
|
28
|
+
locale_1.merge(locale_2, &merger)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Liquid
|
2
|
+
module TemplateInheritance
|
3
|
+
|
4
|
+
# Extends allows designer to use template inheritance
|
5
|
+
#
|
6
|
+
# {% extends home %}
|
7
|
+
# {% block content }Hello world{% endblock %}
|
8
|
+
#
|
9
|
+
class Extends < Block
|
10
|
+
Syntax = /(#{QuotedFragment}+)/o
|
11
|
+
|
12
|
+
def initialize(tag_name, markup, options)
|
13
|
+
super
|
14
|
+
|
15
|
+
if markup =~ Syntax
|
16
|
+
@template_name = $1.gsub(/["']/o, '').strip
|
17
|
+
else
|
18
|
+
raise(SyntaxError.new(options[:locale].t("errors.syntax.extends".freeze)))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def parse(tokens)
|
23
|
+
# get the nodes of the template the object inherits from
|
24
|
+
parent_template = parse_parent_template
|
25
|
+
|
26
|
+
# find the blocks in case there is a call to
|
27
|
+
# the super method inside the current template
|
28
|
+
@options.merge!(:blocks => self.find_blocks(parent_template.root.nodelist))
|
29
|
+
|
30
|
+
# finally, process the rest of the tokens
|
31
|
+
# the tags/blocks other than the InheritedBlock type will be ignored.
|
32
|
+
super
|
33
|
+
|
34
|
+
# replace the nodes of the current template by the ones from the parent
|
35
|
+
@nodelist = parent_template.root.nodelist.clone
|
36
|
+
end
|
37
|
+
|
38
|
+
def blank?
|
39
|
+
false
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
def find_blocks(nodelist, blocks = {})
|
45
|
+
if nodelist
|
46
|
+
nodelist.each_with_index do |node, index|
|
47
|
+
# is the node an inherited block?
|
48
|
+
if node.respond_to?(:call_super)
|
49
|
+
new_node = node.clone_it
|
50
|
+
|
51
|
+
nodelist.insert(index, new_node)
|
52
|
+
nodelist.delete_at(index + 1)
|
53
|
+
|
54
|
+
blocks[node.name] = new_node
|
55
|
+
end
|
56
|
+
if node.respond_to?(:nodelist)
|
57
|
+
# find nested blocks too
|
58
|
+
self.find_blocks(node.nodelist, blocks)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
blocks
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def parse_parent_template
|
68
|
+
source = Template.file_system.read_template_file(@template_name, {})
|
69
|
+
Template.parse(source)
|
70
|
+
end
|
71
|
+
|
72
|
+
def assert_missing_delimitation!
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
Template.register_tag('extends', TemplateInheritance::Extends)
|
79
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module Liquid
|
2
|
+
module TemplateInheritance
|
3
|
+
|
4
|
+
# Blocks are used with the Extends tag to define
|
5
|
+
# the content of blocks. Nested blocks are allowed.
|
6
|
+
#
|
7
|
+
# {% extends home %}
|
8
|
+
# {% block content }Hello world{% endblock %}
|
9
|
+
#
|
10
|
+
class InheritedBlock < Block
|
11
|
+
Syntax = /(#{QuotedFragment}+)/o
|
12
|
+
|
13
|
+
attr_reader :name, :parent
|
14
|
+
|
15
|
+
def initialize(tag_name, markup, options)
|
16
|
+
super
|
17
|
+
|
18
|
+
if markup =~ Syntax
|
19
|
+
@name = $1.gsub(/["']/o, '').strip
|
20
|
+
else
|
21
|
+
raise(SyntaxError.new(options[:locale].t("errors.syntax.inherited_block".freeze)))
|
22
|
+
end
|
23
|
+
|
24
|
+
set_full_name!(options)
|
25
|
+
|
26
|
+
(options[:block_stack] ||= []).push(self)
|
27
|
+
options[:current_block] = self
|
28
|
+
end
|
29
|
+
|
30
|
+
def render(context)
|
31
|
+
context.stack do
|
32
|
+
context['block'] = InheritedBlockDrop.new(self)
|
33
|
+
render_all(@nodelist, context)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def end_tag
|
38
|
+
link_it_with_ancestor
|
39
|
+
|
40
|
+
# clean the stack
|
41
|
+
options[:block_stack].pop
|
42
|
+
options[:current_block] = options[:block_stack].last
|
43
|
+
end
|
44
|
+
|
45
|
+
def call_super(context)
|
46
|
+
if parent
|
47
|
+
parent.render(context)
|
48
|
+
else
|
49
|
+
''
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def clone_it
|
54
|
+
self.class.clone_it(self)
|
55
|
+
end
|
56
|
+
|
57
|
+
def attach_parent(parent, nodelist)
|
58
|
+
@parent = parent
|
59
|
+
@nodelist = nodelist
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.clone_it(block)
|
63
|
+
new_block = new(block.block_name, block.name, {})
|
64
|
+
new_block.attach_parent(block.parent, block.nodelist)
|
65
|
+
new_block
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def set_full_name!(options)
|
71
|
+
if options[:current_block]
|
72
|
+
@name = options[:current_block].name + '/' + @name
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def link_it_with_ancestor
|
77
|
+
options[:blocks] ||= {}
|
78
|
+
|
79
|
+
block = options[:blocks][@name]
|
80
|
+
|
81
|
+
if block
|
82
|
+
# copy/clone the existing block in order to make it a parent of the parsed block
|
83
|
+
cloned_block = block.clone_it
|
84
|
+
|
85
|
+
# replace the up-to-date version of the block in the parent template
|
86
|
+
block.attach_parent(cloned_block, @nodelist)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
Template.register_tag('block', TemplateInheritance::InheritedBlock)
|
94
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
|
5
|
+
require "liquid/template_inheritance/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'liquid-template-inheritance'
|
9
|
+
spec.version = Liquid::TemplateInheritance::VERSION
|
10
|
+
spec.authors = ['Didier Lafforgue', 'Arnaud Sellenet', 'Joel Azemar']
|
11
|
+
spec.email = ['did@locomotivecms.com', 'arnaud@sellenet.fr', 'joel.azemar@gmail.com']
|
12
|
+
spec.description = %q{Liquid addon that enables template inheritance}
|
13
|
+
spec.summary = %q{This is an addon for the liquid templating engine, that adds the ability to inherit from templates}
|
14
|
+
spec.homepage = 'https://github.com/locomotivecms/liquid-template-inheritance'
|
15
|
+
#spec.repo = 'https://github.com/locomotivecms/liquid-template-inheritance'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.1'
|
24
|
+
#spec.add_development_dependency 'liquid', '~> 2.6.1'
|
25
|
+
|
26
|
+
spec.required_ruby_version = '~> 2.0.0'
|
27
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class LayoutFileSystem
|
4
|
+
def read_template_file(template_path, context)
|
5
|
+
case template_path
|
6
|
+
when "base"
|
7
|
+
"<body>base</body>"
|
8
|
+
|
9
|
+
when "inherited"
|
10
|
+
"{% extends base %}"
|
11
|
+
|
12
|
+
when "page_with_title"
|
13
|
+
"<body><h1>{% block title %}Hello{% endblock %}</h1><p>Lorem ipsum</p></body>"
|
14
|
+
|
15
|
+
when "product"
|
16
|
+
"<body><h1>Our product: {{ name }}</h1>{% block info %}{% endblock %}</body>"
|
17
|
+
|
18
|
+
when "product_with_warranty"
|
19
|
+
"{% extends product %}{% block info %}<p>mandatory warranty</p>{% endblock %}"
|
20
|
+
|
21
|
+
when "product_with_static_price"
|
22
|
+
"{% extends product %}{% block info %}<h2>Some info</h2>{% block price %}<p>$42.00</p>{% endblock %}{% endblock %}"
|
23
|
+
|
24
|
+
else
|
25
|
+
template_path
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class ExtendsTagTest < Test::Unit::TestCase
|
31
|
+
include Liquid
|
32
|
+
|
33
|
+
def setup
|
34
|
+
Liquid::Template.file_system = LayoutFileSystem.new
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_template_extends_another_template
|
38
|
+
assert_template_result "<body>base</body>",
|
39
|
+
"{% extends base %}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_template_extends_an_inherited_template
|
43
|
+
assert_template_result "<body>base</body>",
|
44
|
+
"{% extends inherited %}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_template_can_pass_variables_to_the_parent_template
|
48
|
+
assert_template_result "<body><h1>Our product: Macbook</h1></body>",
|
49
|
+
"{% extends product %}", 'name' => 'Macbook'
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_template_can_pass_variables_to_the_inherited_parent_template
|
53
|
+
assert_template_result "<body><h1>Our product: PC</h1><p>mandatory warranty</p></body>",
|
54
|
+
"{% extends product_with_warranty %}", 'name' => 'PC'
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_template_does_not_render_statements_outside_blocks
|
58
|
+
assert_template_result "<body>base</body>",
|
59
|
+
"{% extends base %} Hello world"
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_template_extends_another_template_with_a_single_block
|
63
|
+
assert_template_result "<body><h1>Hello</h1><p>Lorem ipsum</p></body>",
|
64
|
+
"{% extends page_with_title %}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_template_overrides_a_block
|
68
|
+
assert_template_result "<body><h1>Sweet</h1><p>Lorem ipsum</p></body>",
|
69
|
+
"{% extends page_with_title %}{% block title %}Sweet{% endblock %}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_template_has_access_to_the_content_of_the_overriden_block
|
73
|
+
assert_template_result "<body><h1>Hello world</h1><p>Lorem ipsum</p></body>",
|
74
|
+
"{% extends page_with_title %}{% block title %}{{ block.super }} world{% endblock %}"
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_template_accepts_nested_blocks
|
78
|
+
assert_template_result "<body><h1>Our product: iPhone</h1><h2>Some info</h2><p>$42.00</p><p>(not on sale)</p></body>",
|
79
|
+
"{% extends product_with_static_price %}{% block info/price %}{{ block.super }}<p>(not on sale)</p>{% endblock %}", 'name' => 'iPhone'
|
80
|
+
end
|
81
|
+
|
82
|
+
end # ExtendsTagTest
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'test/unit/assertions'
|
5
|
+
begin
|
6
|
+
require 'ruby-debug'
|
7
|
+
rescue LoadError
|
8
|
+
puts "Couldn't load ruby-debug. gem install ruby-debug if you need it."
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'liquid.rb'
|
12
|
+
require 'liquid-template-inheritance'
|
13
|
+
|
14
|
+
module Test
|
15
|
+
module Unit
|
16
|
+
module Assertions
|
17
|
+
include Liquid
|
18
|
+
|
19
|
+
def assert_template_result(expected, template, assigns = {}, message = nil)
|
20
|
+
assert_equal expected, Template.parse(template).render(assigns)
|
21
|
+
end
|
22
|
+
|
23
|
+
def assert_template_result_matches(expected, template, assigns = {}, message = nil)
|
24
|
+
return assert_template_result(expected, template, assigns, message) unless expected.is_a? Regexp
|
25
|
+
|
26
|
+
assert_match expected, Template.parse(template).render(assigns)
|
27
|
+
end
|
28
|
+
end # Assertions
|
29
|
+
end # Unit
|
30
|
+
end # Test
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class I18nUnitTest < Test::Unit::TestCase
|
4
|
+
include Liquid
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@i18n = I18n.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_assign_error
|
11
|
+
assert_equal "Syntax Error in 'assign' - Valid syntax: assign [var] = [source]", @i18n.translate("errors.syntax.assign")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_extends_error
|
15
|
+
assert_equal "Syntax Error in 'extends' - Valid syntax: extends [template]", @i18n.translate("errors.syntax.extends")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_inherited_block_error
|
19
|
+
assert_equal "Syntax Error in 'block' - Valid syntax: block [name]", @i18n.translate("errors.syntax.inherited_block")
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: liquid-template-inheritance
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.6.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Didier Lafforgue
|
8
|
+
- Arnaud Sellenet
|
9
|
+
- Joel Azemar
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.5'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.5'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '10.1'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '10.1'
|
43
|
+
description: Liquid addon that enables template inheritance
|
44
|
+
email:
|
45
|
+
- did@locomotivecms.com
|
46
|
+
- arnaud@sellenet.fr
|
47
|
+
- joel.azemar@gmail.com
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- ".gitignore"
|
53
|
+
- Gemfile
|
54
|
+
- LICENSE
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- lib/liquid-template-inheritance.rb
|
58
|
+
- lib/liquid/template_inheritance/drops/inherited_block_drop.rb
|
59
|
+
- lib/liquid/template_inheritance/i18n.rb
|
60
|
+
- lib/liquid/template_inheritance/locales/en.yml
|
61
|
+
- lib/liquid/template_inheritance/tags/extends.rb
|
62
|
+
- lib/liquid/template_inheritance/tags/inherited_block.rb
|
63
|
+
- lib/liquid/template_inheritance/version.rb
|
64
|
+
- liquid-template-inheritance.gemspec
|
65
|
+
- test/fixtures/en_locale.yml
|
66
|
+
- test/integration/tags/extends_tag_test.rb
|
67
|
+
- test/test_helper.rb
|
68
|
+
- test/unit/i18n_unit_test.rb
|
69
|
+
homepage: https://github.com/locomotivecms/liquid-template-inheritance
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 2.0.0
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.2.2
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: This is an addon for the liquid templating engine, that adds the ability
|
93
|
+
to inherit from templates
|
94
|
+
test_files:
|
95
|
+
- test/fixtures/en_locale.yml
|
96
|
+
- test/integration/tags/extends_tag_test.rb
|
97
|
+
- test/test_helper.rb
|
98
|
+
- test/unit/i18n_unit_test.rb
|