eta-dev / eta

Embedded JS template engine for Node, Deno, and the browser. Lighweight, fast, and pluggable. Written in TypeScript

Home Page:https://eta.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add static helpers

davidmurdoch opened this issue · comments

I'd love to be able to use it like so:

import { Eta } from "eta";

const html = Eta.renderString(myTemplateString, data, options);

// or 

Eta.render("myTemplate.html", data, options);`

Would it be relatively easy to create little static helpers for render and renderString? And if so, would you like a PR for it?

I have only 3 files in my project that need a little templating, and they are all precompiled during compile time -- so no internal cache is needed or used here. While Eta's features are certainly overkill for my needs, it is still small and light weight enough (and already in my transitive dependency tree anyway) to use. It would be nice if it could be use in a one-liner like in my above example.

Since this arguably doesn't add anything too valuable I understand if this interface isn't desired. Please close the issue if that's the case!

You have "only" 3 files in the project but the project is metamask :). Happy to see eta on that.
Is your "problem" write 2 rows instead 1?

Eta < 3 was made in that way (like handlebars and other).
Can you consider to install a 2.x version?

Its not a problem for us to use the current API as is. When I went looking for docs I was hoping there was a static API is all. The current V3 API is fine.

If you do want to add static methods I can send in a PR for it, and if not, I totally understand (and feel free to close this issue)

@davidmurdoch
I answer but I am not the creator ;).
I Answer only to understand better.
What you asked has perfectly sense in my mind.

@davidmurdoch I apologize for the late response! I love MetaMask and am excited to see that you're using eta.

I appreciate the suggestion, but I think it'll be best to leave the API as it is for the sake of not increasing bundle size ;). Feel free to let me know if you have any other questions or suggestions!