pyjade icon indicating copy to clipboard operation
pyjade copied to clipboard

Tag interpolation

Open char101 opened this issue 8 years ago • 3 comments

Tag interpolation [jade issue] [jade commit]

mixin test(tag)
  #{tag} text

+test('div')

Also fix a bug in ext/html.py

def _make_mixin(self, mixin):
    arg_names = [arg.strip() for arg in mixin.args.split(",")]
    def _mixin(self, args):
        if args:
            arg_values = self._do_eval(args)
        else:
            arg_values = []
        if not isinstance(arg_values, (list, tuple)):
            arg_values = [arg_values]
        local_context = dict(zip(arg_names, arg_values))
        with local_context_manager(self, local_context):
            self.visitBlock(mixin.block)
    return _mixin

If arg_values is a string, then local_context will map the parameters into the characters of the string instead of the string value.

char101 avatar Dec 30 '15 10:12 char101