Skip to content

feat: Add suport for custom tag types#364

Open
Tikolu wants to merge 1 commit intobgub:mainfrom
Tikolu:main
Open

feat: Add suport for custom tag types#364
Tikolu wants to merge 1 commit intobgub:mainfrom
Tikolu:main

Conversation

@Tikolu
Copy link

@Tikolu Tikolu commented Feb 27, 2026

Added very basic support for custom tag types.

Example - a "comment" tag <%# ... %> which does nothing, and a localisation tag <%* ... %> which looks up strings in a dictionary.

const translations = {
	en: {greeting: "Hello!"},
	pl: {greeting: "Cześć!"}
}

const eta = new Eta({
	customTags: {
		"#": () => "",
		"*": (key, data) => translations[data.lang][key],
	},
	views: "views"
})

console.log(eta.render("index.html", {
	lang: "en"
}))

And then used in HTML:

<html>
	<%# this is a comment %>
	<p><%* greeting %></p>
</html>

Outputs:

<html>
	<p>Hello!</p>
</html>

@Tikolu Tikolu changed the title Add suport for custom tag types feat: Add suport for custom tag types Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant