SkillAgentSearch skills...

Unja

Template engine for C, inspired by Jinja and Liquid

Install / Use

/learn @dannyvankooten/Unja
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Unja Build Status License: MIT

A template engine for C, inspired by Jinja and Liquid.

This is a work in progress and definitely not usable as it stands.

Example

File base.tmpl:

<html>
	<head><title>{% block title %}Default title{% endblock %}</title></head>
	<body>
		{% block content %}
		{% endblock %}
	</body>
</html>

File child.tmpl:

{% extends "base.html" %}

{% block title %}Users{% endblock %}

{% block content %}
	<ul>
	{% for user in users %}
		<li><a href="{{ user.url }}">{{ user.username | lower }}</a></li>
	{% endfor %}
	</ul>
{% endblock %}

File: example.c

int main() {
	// parse all templates in the given directory
	struct env *env = env_new("./");

	// create a hashmap for storing template variables
	struct hashmap *vars = hashmap_new();
	hashmap_insert(vars, "name", "John Doe");

	// execute the template
	char *output = template(env, "child.tmpl", vars);
	printf("%s", output);

	// clean-up allocated memory
	free(output);
	hashmap_free(vars);
	env_free(env);
}

License

MIT

Related Skills

View on GitHub
GitHub Stars14
CategoryDevelopment
Updated1y ago
Forks2

Languages

C

Security Score

80/100

Audited on Aug 20, 2024

No findings