Commit Graph
58 Commits
Author SHA1 Message Date
Mike Angell cbea19b59f Switch to aliasing methods 2019-08-31 20:32:07 +10:00
Mike Angell 0521d78b30 Initial concept 2019-08-30 14:29:07 +10:00
Samuel 9672ed5285 Add a new {% render %} tag
Example:

```
// the_count.liquid
{{ number }}! Ah ah ah.

// my_template.liquid
{% for number in range (1..3) %}
  {% render "the_count", number: number %}
{% endfor %}

Output:
1! Ah ah ah.
2! Ah ah ah.
3! Ah ah ah.
```

The `render` tag is a more strict version of the `include` tag. It is
designed to isolate itself from the parent rendering context both by
creating a new scope (which does not inherit the parent scope) and by
only inheriting "static" registers.

Static registers are those that do not hold mutable state which could
affect rendering. This again helps `render`ed templates remain entirely
separate from their calling context.

Unlike `include`, `render` does not permit specifying the target
template using a variable, only a string literal. For example, this
means that `{% render my_dynamic_template %}` is invalid syntax. This
will make it possible to statically analyze the dependencies between
templates without making Turing angry.

Note that the `static_environment` of a rendered template is inherited, unlike
the scope and regular environment. This environment is immutable from within the
template.

An alternate syntax, which mimics the `{% include ... for %}` tag is
currently in design discussion.
2019-08-29 16:32:05 -04:00
Stephen Paul Weber 7d13d88258 s/Traversal/ParseTreeVisitor 2018-10-18 09:38:33 -04:00
Stephen Paul Weber c11fc656cf Colocate Traversal classes with classes they traverse
This puts all knowledge of the traversal in the same file, and removes
the need for a CASES registry.
2018-10-18 09:37:48 -04:00
Michael Angell e1d40c7d89 Add whitespace control character and associated tests 2016-06-28 09:15:45 +10:00
Florian Weingarten 79e2d1d8b4 Liquid::TablerowloopDrop 2016-01-08 18:46:23 +00:00
Florian Weingarten e113c891ec Convert forloop hash to drop 2016-01-06 21:30:32 +00:00
Dylan Thacker-Smith cebf75b8d7 Implement line numbers without the Liquid::Token class. 2015-07-08 19:21:59 -04:00
Gaurav Chande 8b98f92c7f Extract tokenize logic from Template to a RubyTokenizer 2015-06-04 04:39:30 +00:00
Florian Weingarten f4724f0db3 Remove support for liquid_methods Module extension 2015-05-14 14:44:19 +00:00
Jean Boussier b31df0fb3d Mordernize code base with __dir__ and require_relative 2015-05-13 15:33:00 -04:00
Justin Li e2f8b28f56 Merge pull request #492 from Shopify/resource-counting-perf
Resource counting perf
2014-12-11 16:05:41 -05:00
Justin Li dd455a6361 Force user to require the profiler themselves 2014-12-04 17:48:26 -05:00
Justin Li 8c70682d6b Don't automatically load hooks 2014-12-04 17:39:41 -05:00
Justin Li db00ec8b32 Move resource limit tracking to its own class 2014-12-04 16:18:09 -05:00
Justin Li c0aab820ed Lazily load profiler hooks 2014-11-12 00:05:01 -05:00
Dylan Thacker-SmithandJustin Li 73fcd42403 Create a BlockBody class to decouple block body parsing from tags. 2014-11-03 17:07:42 -05:00
Tristan HumeandFlorian Weingarten 3a0ee6ae91 Remove parser switching duplication 2014-09-05 14:12:29 +00:00
Florian Weingarten 5eff375094 Optional line numbers for liquid errors 2014-09-05 14:12:29 +00:00
Jason Roelofs 173a58d36a Profile liquid rendering
Add a simple profiling system to liquid rendering. Each
liquid tag ({{ }} and {% %}) is processed through this profiling,
keeping track of the partial name (in the case of {% include %}), line
number, and the time it took to render the tag. In the case of {%
include %}, the profiler keeps track of the name of the partial and
properly links back tag rendering to the partial and line number for
easy lookup and dive down. With this, it's now possible to track down
exactly how long each tag takes to render.

These hooks get installed and uninstalled on an as-need basis so by
default there is no impact on the overall liquid execution speed.
2014-08-12 15:37:21 -04:00
Dylan Thacker-Smith 2aa9bbbac2 Separate expression parsing and rendering from Context#resolve. 2014-08-11 14:15:58 -07:00
David Cornu f57383af37 Allow tag classes to be reloaded when using Liquid.cache_classes is false
Because Liquid keeps a reference to tag classes, Rails class reloading may
cause problems with custom tags. This commit introduces a setting that
allows these classes to be resolved when required.
2014-07-02 20:03:18 +00:00
Florian Weingarten 3dbb35d823 Merge branch 'freeze_all_the_things'
Conflicts:
	History.md
	lib/liquid/tags/assign.rb
	lib/liquid/tags/capture.rb
	lib/liquid/tags/decrement.rb
	lib/liquid/tags/if.rb
2014-03-24 12:39:34 -04:00
Dylan Thacker-Smith fdf03076e0 Revert "Merge pull request #325 from Shopify/remove-variable-incomplete-end"
That pull request broke raw tags with open variable tags. E.g.

{% raw %}
{{
{% endraw %}
{{ 1 }}

This reverts commit fbaabf3b59, reversing
changes made to af24d2c2ab.
2014-03-24 09:59:07 -04:00
Dylan Thacker-Smith d8d9984a7b Remove some unused regexes. 2014-03-21 15:50:14 -04:00
Dylan Thacker-Smith 7e0ef867d2 Make tag/variable termination error clearer. 2014-03-21 02:04:01 -04:00
Dylan Thacker-Smith 3682414cc4 Allow quoted single curly braces in variables. 2014-03-21 02:04:01 -04:00
Dylan Thacker-Smith 3b14e27f55 Allow newlines in tags and variables. 2014-03-20 17:27:03 -04:00
Dylan Thacker-Smith 92781ec43b Move definition for TableRow to the tags folder. 2014-03-18 17:13:39 -04:00
Dylan Thacker-Smith 503d924274 Use start and end of string rather than line matching in regexes. 2014-03-13 17:56:42 -04:00
Florian Weingarten 43ac8d560b Freeze all the things 2014-01-07 12:35:16 -05:00
Simon Eskildsen f37a984fd7 Add sketch of I18n error translation 2013-08-30 12:31:57 -04:00
Tristan Hume 76272a1afa Bring back the lexer 2013-07-24 14:40:29 -04:00
Tristan Hume ee14775f83 Replace hand-coded lexer with faster hacky lexer. 2013-07-24 11:41:47 -04:00
Tristan Hume 2332d86156 Slow lexer and parser scaffold. 2013-07-24 11:35:00 -04:00
Arthur Neves 1849c24f2c Adding version file
Follow the standard structure of having a version.rb file
2013-06-06 14:10:45 -04:00
Tom Burns 8913a5615a Revert "Merge pull request #185 from ISSIntel/liquid-utf8"
This reverts commit c5dfcd29b0, reversing
changes made to f7d1e1d0c1.
2013-05-20 19:53:13 -04:00
Adam Tanner 0b36540b78 Liquid has UTF8 support. 2012-12-26 18:14:36 -08:00
Jon Daniel 9c183bea83 added interrupt class for continue/break statements
When a continue or break statement is executed it pushes an interrupt to a
stack in context. If any non-handled interrupts are present blocks will cease
to execute. The for loop can handle the most recent interrupt in the stack.
2012-08-21 13:14:27 -04:00
Dylan Smith d0184555d9 Allow tablerow to work with any Enumerable. Closes #132 2012-06-20 11:07:11 -04:00
Michael Green 281e3ea9c8 add interpolate once flag to regexes that never change 2012-05-08 16:27:50 -07:00
Jonathan Rudenberg 2434c3d0e0 Remove duplicate commas from StrictQuotedFragment. Closes #26. 2011-07-12 09:18:46 -04:00
Jonathan Rudenberg 4aaf750fa8 Don't mess with the load path 2011-06-30 16:31:37 -04:00
Jonathan Rudenberg f85bea2902 Remove literal tag (raw is more performant)
This reverts commit c00a650492.
2011-06-13 09:34:15 -04:00
DBAandTobias Lütke 3d43efe2bc Ruby compatibility issues
- regexp engines are different from 1.8 to 1.9, fixed the literal shorthand regexp accordingly
  - changed the shorthand regexp text from a match to a string scan
  - test_helper now loads rubygems unless RUBY_VERSION is > 1.9
2010-08-24 08:17:42 +08:00
DBAandTobias Lütke c00a650492 Literal
- added support for literals [closes #6]

Code beautifier
  - indented some files
2010-08-24 08:17:42 +08:00
DBAandTobias Lütke 8a0a8cfd99 FiltersTest
- added test that asserts nonexistent filters are ignored

Liquid
  - Bill's mind blowing liquid patch to support filter separators (|) in quoted strings (svn r7516).
  - This is a consolidation effort based on newrelic's liquid fork commit 88a5b891d009054d56b994c9448725c74e2b1e13
2010-08-23 01:30:05 +08:00
James MacAulay 2d0532e041 QuotedStrings can be empty 2009-08-19 18:37:40 -04:00
Brian Candler f29b9335c5 Allow question-mark at end of variable name only 2009-06-06 16:20:34 +01:00