def parse(cls, parser, token): """ Parse the node syntax: .. code-block:: html+django {% page_placeholder parentobj slotname title="test" role="m" %} """ bits = token.split_contents() arg_bits, kwarg_bits = parse_token_kwargs(parser, bits, True, True, ('title', 'role', 'template')) if len(arg_bits) == 2: (parent_expr, slot_expr) = arg_bits elif len(arg_bits) == 1: # Allow 'page' by default. Works with most CMS'es, including django-fluent-pages. (parent_expr, slot_expr) = (Variable('page'), arg_bits[0]) else: raise TemplateSyntaxError("""{0} tag allows two arguments: 'parent object' 'slot name' and optionally: title=".." role="..".""".format(bits[0])) template = kwarg_bits.pop('template', None) return cls( parent_expr=parent_expr, slot_expr=slot_expr, template_expr=template, meta_kwargs=kwarg_bits )
def parse(cls, parser, token): """ Parse the node syntax: .. code-block:: html+django {% page_placeholder parentobj slotname title="test" role="m" %} """ bits = token.split_contents() arg_bits, kwarg_bits = parse_token_kwargs( parser, bits, True, True, ('title', 'role', 'template')) if len(arg_bits) == 2: (parent_expr, slot_expr) = arg_bits elif len(arg_bits) == 1: # Allow 'page' by default. Works with most CMS'es, including django-fluent-pages. (parent_expr, slot_expr) = (Variable('page'), arg_bits[0]) else: raise TemplateSyntaxError( """{0} tag allows two arguments: 'parent object' 'slot name' and optionally: title=".." role="..".""" .format(bits[0])) template = kwarg_bits.pop('template', None) return cls(parent_expr=parent_expr, slot_expr=slot_expr, template_expr=template, meta_kwargs=kwarg_bits)
def parse(cls, parser, token): """ Parse the node syntax: .. code-block:: html+django {% sharedcontent slotname template="" %} """ bits = token.split_contents() arg_bits, kwarg_bits = parse_token_kwargs(parser, bits, True, True, ('template',)) if len(arg_bits) == 1: slot_expr = arg_bits[0] else: raise TemplateSyntaxError("""{0} tag allows one arguments: 'slot name' and optionally: template="..".""".format(bits[0])) template = kwarg_bits.pop('template', None) return cls( slot_expr=slot_expr, template_expr=template, )