Frontends

Eta

Edit on GitHub

This handler module serves Eta components with the .eta extension.

Install

npm install @primate/eta

Configure

Import and initialize the module in your configuration.

primate.config.js
import eta from "@primate/eta";

export default {
  modules: [
    eta(),
  ],
};

Use

Create an Eta component in components.

components/post-index.eta
<h1>All posts</h1>
<div>
<% it.posts.forEach(function(post){ %>
<h2><a href="/post/view/<%= post.id %>"><%= post.title %></a></h2>
<% }) %>
</div>

Serve it from a route.

routes/eta.js
import view from "primate/handler/view";

const posts = [{
  id: 1,
  title: "First post",
}];

export default {
  get() {
    return view("post-index.eta", { posts });
  },
};

The rendered component will be accessible at http://localhost:6161/eta.

Configuration options

extension

Default ".eta"

The file extension associated with Eta components.

Resources

Previous
Angular
Next
Handlebars