Skip to content

maiqingqiang/Jinja

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jinja

A minimalistic Swift implementation of the Jinja templating engine, specifically designed for parsing and rendering ML chat templates.

SwiftPM

To use Jinja with SwiftPM, you can add this to your Package.swift:

dependencies: [
    .package(url: "https://github.com/maiqingqiang/Jinja", branch: "main")
]

And then, add the Transformers library as a dependency to your target:

targets: [
    .target(
        name: "YourTargetName",
        dependencies: [
            .product(name: "Jinja", package: "Jinja")
        ]
    )
]

Usage

import Jinja

let template = """
{% for item in items %}
{{ item }}
{% endfor %}
"""

let context = [
    "items": [
        "item1", 
        "item2", 
        "item3"
    ]
]

let result = try Template(template).render(context)

About

A minimalistic Swift implementation of the Jinja templating engine, specifically designed for parsing and rendering ML chat templates.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages