Skip to content

liquid.exts.front_matter

module

liquid.exts.front_matter

Provides an extension to allow front matter in the template

Classes
class

liquid.exts.front_matter.FrontMatterExtension(environment)

Bases
jinja2.ext.Extension

This extension allows to have front matter

Methods
  • __init_subclass__() This method is called when a class is subclassed.</>
  • attr(name, lineno) (ExtensionAttribute) Return an attribute node for the current extension. This is usefulto pass constants on extensions to generated template code. </>
  • bind(environment) (Extension) Create a copy of this extension bound to another environment.</>
  • call_method(name, args, kwargs, dyn_args, dyn_kwargs, lineno) (Call) Call a method of the extension. This is a shortcut for:meth:attr + :class:jinja2.nodes.Call. </>
  • filter_stream(stream) (Union(tokenstream, iterable of token)) It's passed a :class:~jinja2.lexer.TokenStream that can be usedto filter tokens returned. This method has to return an iterable of :class:~jinja2.lexer.Token\s, but it doesn't have to return a :class:~jinja2.lexer.TokenStream. </>
  • parse(parser) (Union(node, list of node)) If any of the :attr:tags matched this method is called with theparser as first argument. The token the parser stream is pointing at is the name token that matched. This method has to return one or a list of multiple nodes. </>
  • preprocess(source, name, filename) (str) Preprocess sourcee to extract front matter</>
classmethod

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

method

bind(environment) → Extension

Create a copy of this extension bound to another environment.

method

filter_stream(stream) → Union(tokenstream, iterable of token)

It's passed a :class:~jinja2.lexer.TokenStream that can be usedto filter tokens returned. This method has to return an iterable of :class:~jinja2.lexer.Token\s, but it doesn't have to return a :class:~jinja2.lexer.TokenStream.

method

parse(parser) → Union(node, list of node)

If any of the :attr:tags matched this method is called with theparser as first argument. The token the parser stream is pointing at is the name token that matched. This method has to return one or a list of multiple nodes.

method

attr(name, lineno=None) → ExtensionAttribute

Return an attribute node for the current extension. This is usefulto pass constants on extensions to generated template code.

::

self.attr('_my_attribute', lineno=lineno)
method

call_method(name, args=None, kwargs=None, dyn_args=None, dyn_kwargs=None, lineno=None) → Call

Call a method of the extension. This is a shortcut for:meth:attr + :class:jinja2.nodes.Call.

method

preprocess(source, name, filename=None) → str

Preprocess sourcee to extract front matter