-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
12 changed files
with
287 additions
and
515 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Liquid | ||
class PartialCache | ||
def self.load(template_name, context:, parse_context:) | ||
cached_partials = (context.registers[:cached_partials] ||= {}) | ||
cached = cached_partials[template_name] | ||
return cached if cached | ||
|
||
file_system = (context.registers[:file_system] ||= Liquid::Template.file_system) | ||
source = file_system.read_template_file(template_name) | ||
parse_context.partial = true | ||
|
||
partial = Liquid::Template.parse(source, parse_context) | ||
cached_partials[template_name] = partial | ||
ensure | ||
parse_context.partial = false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.