Skip to content

Implement Jinja3 for variable value and filters #338

Closed

Description

@0hsn
No description provided.

Activity

  1. 0hsn commented on Dec 1, 2024

    @0hsn
    MemberAuthor

    Working prototype

    from jinja2.nativetypes import NativeEnvironment
    
    native_env = NativeEnvironment(
        variable_start_string="<%",
        variable_end_string="%>",
        block_start_string="<@",
        block_end_string="@>",
        comment_start_string="<#",
        comment_end_string="#>",
    )
    
    data = {
        "a": {
            "b": {
                "c": [1, 2],
                "cstr": "Some string",
                "cfloat": 0.0025,
            }
        }
    }
    
    t = native_env.from_string('<% a.b.c %>')
    s = t.render(data)
    ...
    t = native_env.from_string('<% a.b.cstr|upper %> | <% a.b.cfloat|round %>')
    s = t.render(data)
  2. changed the title [-][IDEA] Implement Jinja3 for variable value and filters[/-] [+]Implement Jinja3 for variable value and filters[/+] on Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions