Eta

Use the template engine Eta to build pages.

Options See on deno.land

extensions string[] object

The list of extensions this plugin applies to

Default:
[ ".eta" ]
includes string

Custom includes path

Default:
""
options object

Configuration to pass to Eta

autoEscape boolean

Whether or not to automatically XML-escape interpolations. Default true

autoFilter boolean

Apply a filter function defined on the class to every interpolation or raw interpolation

autoTrim object [object, object]

Configure automatic whitespace trimming. Default [false, 'nl']

cache boolean

Whether or not to cache templates if name or filename is passed

cacheFilepaths boolean

Holds cache of resolved filepaths. Set to false to disable.

debug boolean

Whether to pretty-format error messages (introduces runtime penalties)

escapeFunction function

Function to XML-sanitize interpolations

filterFunction function

Function applied to all interpolations when autoFilter is true

functionHeader string

Raw JS code inserted in the template function. Useful for declaring global variables for user templates

parse object

Parsing options

plugins object

Array of plugins

rmWhitespace boolean

Remove all safe-to-remove whitespace

tags [string, string]

Delimiters: by default ['<%', '%>']

useWith boolean

Make data available on the global object instead of varName

Default:
true
varName string

Name of the data object. Default it

views string

Directory that contains templates

Description

Eta is a JavaScript template engine with a syntax very similar to EJS but with some differences. This plugin allows using this template engine to create pages and layouts.

Installation

Import this plugin in your _config.ts file to use it:

import lume from "lume/mod.ts";
import eta from "lume/plugins/eta.ts";

const site = lume();

site.use(eta(/* Options */));

export default site;

Creating layouts

Add a file with .eta extension in the _includes directory. Use the layout page variable to specify this layout.

---
title: Welcome to my page
intro: This is my first post using lume, I hope you like it!
---

<html>
  <head>
    <title><%= title %></title>
  </head>

  <body>
    <%~ await includeFile("partials/nav.eta") %>

    <p><%= title %></p>
  </body>
</html>

Note that the paths passed to includeFile() function are always relative to _includes directory.

Creating pages

Creating pages is the same as creating layouts, just place the .eta file outside the _includes directory.

Configure VSCode

You can use the Eta extension for VS Code for syntax highlight and some useful snippets.