3.5.0 β€’ Published 3 months ago

eta v3.5.0

Weekly downloads
39,572
License
MIT
Repository
github
Last release
3 months ago

GitHub package.json version (main) GitHub Actions Status All Contributors Coveralls Donate

You're viewing the source for Eta v3, which we just released! For v2, visit the old branch.

Summary

Eta is a lightweight and blazing fast embedded JS templating engine that works inside Node, Deno, and the browser. It's written in TypeScript and emphasizes great performance, configurability, and small bundle size.

🌟 Features

  • πŸ“¦ 0 dependencies
  • πŸ’‘ Only ~3.5 KB minzipped
  • ⚑️ Written in TypeScript
  • ✨ Deno support (+ Node and browser)
  • πŸš€ Super Fast
  • πŸ”§ Configurable
    • Plugins, custom delimiters, caching
  • πŸ”¨ Powerful
    • Precompilation, partials, async
    • Layout support!
  • πŸ”₯ Reliable
    • Better quotes/comments support
      • ex. <%= someval + "string %>" %> compiles correctly, while it fails with doT or EJS
    • Great error reporting
  • ⚑️ Exports ES Modules as well as UMD
  • πŸ“ Easy template syntax

Get Started

For more thorough documentation, visit https://eta.js.org

Install Eta

npm install eta

In the root of your project, create templates/simple.eta

Hi <%= it.name %>!

Then, in your JS file:

import { Eta } from "eta";
// import { Eta } from "https://deno.land/x/eta@v3.1.0/src/index.ts";

const eta = new Eta({ views: path.join(__dirname, "templates") });

// Render a template

const res = eta.render("./simple", { name: "Ben" });
console.log(res); // Hi Ben!

FAQs

"Eta" means tiny in Esperanto. Plus, it can be used as an acronym for all sorts of cool phrases: "ECMAScript Template Awesomeness", "Embedded Templating Alternative", etc....

Additionally, Eta is a letter of the Greek alphabet (it stands for all sorts of cool things in various mathematical fields, including efficiency) and is three letters long (perfect for a file extension).

Integrations

@shadowtime2000 created eta-vscode.

eslint-plugin-eta was created to provide an ESLint processor so you can lint your Eta templates.

Currently there is no official Webpack integration but @clshortfuse shared the loader he uses:

{
  loader: 'html-loader',
  options: {
    preprocessor(content, loaderContext) {
      return eta.render(content, {}, { filename: loaderContext.resourcePath });
    },
  },
}

To operate with Eta templates in Node-RED: @ralphwetzel/node-red-contrib-eta

To render Eta templates in Koa web framework: @cedx/koa-eta

Projects using eta

  • Docusaurus v2: open-source documentation framework that uses Eta to generate a SSR build
  • swagger-typescript-api: Open source typescript api codegenerator from Swagger. Uses Eta as codegenerator by templates
  • html-bundler-webpack-plugin: Webpack plugin make easily to bundle HTML pages from templates, source styles and scripts
  • SmartDeno: SmartDeno is an easy to setup web template using Deno & Oak
  • stc: OpenAPI (Swagger) and Apifox documentation converted to api. Use eta templates to generate code.
  • Add yours!

Contributors

Made with ❀ by @nebrelbug and all these wonderful contributors (emoji key):

This project follows the all-contributors specification. Contributions of any kind are welcome!

Credits

  • Async support, file handling, and error formatting were based on code from EJS, which is licensed under the Apache-2.0 license. Code was modified and refactored to some extent.
  • Syntax and some parts of compilation are heavily based off EJS, Nunjucks, and doT.
pipelinit-a6fbdba0bsa-core@savant/coretemplater-obsidian@infinitebrahmanuniverse/nolb-etalaravel-mix-etavlang-playground@everything-registry/sub-chunk-1618begat@signal24/deepkit-extensionseta-ssgsvgicowhatsapp2htmlrn-tokriptsexy-serverrollup-plugin-etasuper-sveltekit-clisubjektifystories-to-testsspartan-swagger-typescript-api-generatorswagger-typescript-api-16swagger-typescript-api-3swagger-typescript-api-altswagger-typescript-api-esswagger-typescript-api-fixswagger-typescript-api-from-openai-2.0-fixswagger-typescript-api-nextgenswagger-typescript-apiswagger-typescript-api-ts-patchswaggieswaggie-betathoughtbeltvite-plugin-marked-mpavite-etavite-plugin-etavertis@phyla/template@galxe-protocol/galxe-protocol-sdksaucer-appvortex-core-cli-nextlearnpackgoat-bot-v2json-server-extendedjsonresume-theme-traditionaljson-serverjson-server-aminmorphogenkoa-etahtml-bundler-webpack-pluginhpr_clikb-generator-tsjp-cli-forkhardhat_metamask_clienthardhat_metamask_client2gita-ssoglypfigncms-ssgmarjory-climarkdown-buildmarilenamec-testmaildownnodelinkpamtagparcel-transformer-etaparcel-transformer-etajspancakeiopipelinitoidc-provideroidc-provider-cjsoidc-provider-ilkkahoidc-provider-nodejsoculimypluginlolracejdocqdkreact-svg-codegenspawn-playgroundskuts-drytiny-react-clitokript@authok/oidc-provider@asset-toolkit/template-transform@advect/advect@aleclarson/swagger-typescript-api@blackdark/swagger-typescript-api@bfrankovskyi/jscli@bhuma.dev/react-dashboard@cedx/koa-eta@charlytoc/learnpack@chirpy-dev/docker-cli@chirpy-dev/emails@chirpy-dev/main-app@1023-ventures/basalt@9paradox/apitester@digigov/swagger-typescript-apiyablokozr-swagger-apiwebpagetoccode
3.4.1

4 months ago

3.5.0

3 months ago

3.4.0

8 months ago

3.3.0

8 months ago

3.2.0

12 months ago

3.1.1

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago

3.1.0

1 year ago

2.2.0

2 years ago

3.0.1

1 year ago

3.0.0

1 year ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

1.14.1

2 years ago

1.14.0

2 years ago

1.13.0

2 years ago

1.14.2

2 years ago

2.0.0

2 years ago

1.12.3

3 years ago

1.12.2

3 years ago

1.12.1

4 years ago

1.12.0

4 years ago

1.11.0

4 years ago

1.10.1

4 years ago

1.9.0

4 years ago

1.10.0

4 years ago

1.8.0

4 years ago

1.7.0

4 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.0.0-beta.4

5 years ago

1.0.0-beta.3

5 years ago

1.0.0-beta.2

5 years ago

1.0.0-beta.1

5 years ago

1.0.0-beta.0

5 years ago

0.0.0

12 years ago