New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

atlatl

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atlatl

Atlatl is a templating language for Node. It is inspired by Jinja and Laravel's Blade.

  • 5.6.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-42.86%
Maintainers
1
Weekly downloads
 
Created
Source

Atlatl

Atlatl is a templating language for Node. It is inspired by Jinja and Laravel's Blade.

It could be thought of as a superset of ES6 template strings that adds object oriented features, logic, and default escaping of html.

It looks like this.

@partial title (title)
  <title>${ title }</title>
@

<!doctype html>
<html>
  <head>
    @yield head
  </head>
  <body>
    @section main
      ${ safe(content.content) }
    @
  </body>
</html>
@extends layout.html

@section head
  @call title ('Posts')
@

@section main
  <ul>
    @each content.posts (post)
      <li><a href="${ post.permalink }">${ safe(post.title) } &mdash; ${ post.date }</a></li>
    @
  </ul>
@

Lines that begin with an @ are called directives. Some directives are one line. Others are blocks and must be closed with a line with just an @.

HTML output by ES6 templates' ${ ... } is escaped by default but the safe function can be used to mark code to not escape.

The Directives

Logic and Loops

@each var (val, [key])

Loops through an array. Block level.

@if (condition)

Just like any other if statement. Block level.

Methods

@partial name ([arg1, [ ...argN]])

Defines a method that can be called with @call. Block level.

@call name ([arg1, [ ...argN]])

Calls a method. If it is not defined an error will occur.

@section name

Defines and calls a method that can be overridden when the template is extended. Block level.

@yield name

Defines and calls a method. A placeholder. Great for templates that are meant to be extended.

Inheritance

@extends template

Used to extend another template. The methods (sections and partials) in the extending template override methods in the extended template and any output outside of methods is ignored.

@import name template [method]

Can import partials or sections (any method) from another file. Use method to rename the method being imported. If method is not set then the name as defined is used.

@parent [name] ([arg1, [ ...argN]])

In a template that extends another template it calls an overridden method. If name is not defined it calls the same method in which it appears.

The Result

Each template is transformed into a CommonJS module that exports a class.

FAQs

Package last updated on 01 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc