npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@scaffdog/engine

v4.0.0

Published

A module of scaffdog template engine.

Downloads

114,170

Readme

@scaffdog/engine

A module of scaffdog template engine.

Install

Install via npm:

$ npm install @scaffdog/engine

Usage

The following code is a basic example:

import { render, createContext } from '@scaffdog/engine';

const context = createContext({
  variables: new Map([['name', 'scaffdog']]),
  helpers: new Map([['greet', (_, name: string) => `Hi ${name}!`]]),
});

const output = render(`OUTPUT: {{ name | greet }}`, context);
// --> "OUTPUT: Hi scaffdog!"

Custom Tags

You can change the tag delimiter with context.tags:

import { render, createContext } from '@scaffdog/engine';

const context = createContext({
  tags: ['<%=', '=%>'],
});

render(`<%= "custom tag" =%>`, context);

Language Specification

scaffdog uses the template engine inpired by ECMAScript and Go text/template.

SourceCharacter ::= #x0000-#x10FFFF
WhiteSpace ::= "<TAB>" | "<LF>" | "<CR>" | " "

Comment ::= "/*" CommentChars? "*/"
CommentChars ::= NotAsteriskChar CommentChars? | "*" PostAsteriskCommentChars?
PostAsteriskCommentChars ::= NotForwardSlashOrAsteriskChar CommentChars? | "*" PostAsteriskCommentChars?
NotAsteriskChar ::= [^*]
NotForwardSlashOrAsteriskChar ::= [^/*]
NonZeroDigit ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
Digit ::= "0" | NonZeroDigit

NullLiteral ::= "null"
UndefinedLiteral ::= "undefined"
BooleanLiteral ::= "true" | "false"
NumericLiteral ::= DecimalLiteral | BinaryIntegerLiteral | OctalIntegerLiteral | HexIntegerLiteral
DecimalLiteral ::= DecimalIntegerLiteral "." DecimalDigits? ExponentPart?
  | "." DecimalDigits ExponentPart?
  | DecimalIntegerLiteral ExponentPart?
DecimalIntegerLiteral ::= "0"
  | NonZeroDigit
  | NonZeroDigit DecimalDigits
DecimalDigits ::= Digit | DecimalDigits Digit
ExponentPart ::= ExponentIndicator SignedInteger
ExponentIndicator ::= "e" | "E"
SignedInteger ::= DecimalDigits | "+" DecimalDigits | "-" DecimalDigits
BinaryIntegerLiteral ::= "0b" BinaryDigits | "0B" BinaryDigits
BinaryDigits ::= BinaryDigit | BinaryDigits BinaryDigit
BinaryDigit ::= "0" | "1"
OctalIntegerLiteral ::= "0o" OctalDigits | "0O" OctalDigits
OctalDigits ::= OctalDigit | OctalDigits OctalDigit
OctalDigit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7"
HexIntegerLiteral ::= "0x" HexDigits | "0X" HexDigits
HexDigits ::= HexDigit | HexDigits HexDigit
HexDigit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F"
StringLiteral ::= DoubleStringLiteral | SingleStringLiteral
DoubleStringLiteral ::= '"' DoubleStringChars '"'
DoubleStringChars ::= DoubleStringChar | DoubleStringChar DoubleStringChars
DoubleStringChar ::= EscapeChar | SourceCharacter - '"'
SingleStringLiteral ::= '"' SingleStringChars '"'
SingleStringChars ::= SingleStringChar | SingleStringChar SingleStringChars
SingleStringChar ::= EscapeChar | SourceCharacter - "'"
EscapeChar ::= '\"' | "\'"

Literal ::= NullLiteral | UndefinedLiteral | BooleanLiteral | NumericLiteral | StringLiteral

ReservedWord ::= "null" | "true" | "false" | "undefined" | "if" | "else" | "break" | "continue" | "end" | "for"

/* Expressions */
Identifier ::= IdentifierName - ReservedWord
IdentifierName ::= IdentifierStart | IdentifierName IdentifierPart
IdentifierStart ::= "$" | "_" | UnicodeIDStart
IdentifierPart ::= "$" | "_" | UnicodeIDContinue
UnicodeIDStart ::= /* any Unicode code point with the Unicode property “ID_Start” */
UnicodeIDContinue ::= /* any Unicode code point with the Unicode property “ID_Continue” */

PrimaryExpression ::= Identifier
  | Literal
  | ParenthesizedExpression

StaticMemberAccessor ::= Identifier | NumericLiteral
MemberExpression ::= PrimaryExpression
  | MemberExpression "[" Expression "]"
  | MemberExpression "." StaticMemberAccessor

CallExpression ::= MemberExpression Arguments
  | CallExpression Arguments
  | CallExpression "[" Expression "]"
  | CallExpression "." StaticMemberAccessor

LeftHandSideExpression ::= CallExpression | MemberExpression
UpdateExpression ::= LeftHandSideExpression
  | LeftHandSideExpression "++"
  | LeftHandSideExpression "--"
  | "++" LeftHandSideExpression
  | "--" LeftHandSideExpression
UnaryExpression ::= UpdateExpression |
  | "+" UnaryExpression
  | "-" UnaryExpression
  | "~" UnaryExpression
  | "!" UnaryExpression

MultiplicativeOperator ::= [* / %]
MultiplicativeExpression ::= UnaryExpression
  | MultiplicativeExpression MultiplicativeOperator UnaryExpression
AdditiveExpression ::= MultiplicativeExpression
  | AdditiveExpression "+" MultiplicativeExpression
  | AdditiveExpression "-" MultiplicativeExpression
RelationalExpression::= AdditiveExpression
  | RelationalExpression "<" AdditiveExpression
  | RelationalExpression ">" AdditiveExpression
  | RelationalExpression "<=" AdditiveExpression
  | RelationalExpression ">=" AdditiveExpression

EqualityExpression ::= RelationalExpression
  | EqualityExpression "==" RelationalExpression
  | EqualityExpression "!=" RelationalExpression

LogicalANDExpression ::= LogicalANDExpression "&&" EqualityExpression
LogicalORExpression ::= LogicalORExpression "||" LogicalANDExpression

ConditionalExpression ::= LogicalORExpression
  | ConditionalExpression "?" ConditionalExpression ":" ConditionalExpression

ArgumentItem ::= ConditionalExpression | CallExpression
ArgumentList ::= ArgumentItem | ArgumentList "," ArgumentItem
Arguments ::= "(" ")" | "(" ArgumentList ")"

ParenthesizedExpression ::= "(" Expression ")"

PipeArgument ::= UnaryExpression
PipeArgumentList ::= PipeArgument | PipeArgumentList WhiteSpace PipeArgument
PipeHead ::= ConditionalExpression PipeArgumentList?
  | LeftHandSideExpression PipeArgumentList?
PipeBody ::= MemberExpression PipeArgumentList?
PipeExpression ::= PipeHead
  | PipeHead "|" PipeBody
  | PipeExpression "|" PipeBody

Expression ::= PipeExpression

/* Statements */
TagOpen ::= "{{" | "{{-"
TagClose ::= "}}" | "}}-"

ExpressionStatement ::= Expression
VariableStatement ::= Identifier ":=" Expression
EndStatement ::= "end"
ContinueStatement ::= "continue"
BreakStatement ::= "break"
ForBinding ::= Identifier | Identifier "," Identifier
ForStatement ::= "for" ForBinding "in" Expression TagClose Template TagOpen EndStatement
IfStatement ::= "if" Expression TagClose Template TagOpen EndStatement
  | "if" Expression TagClose Template TagOpen "else" TagClose Template TagOpen EndStatement
  | "if" Expression TagClose Template TagOpen "else" IfStatement
Statement ::= VariableStatement
  | IfStatement
  | ForStatement
  | ContinueStatement
  | BreakStatement
  | ExpressionStatement

/* Templates */
TagTemplate ::= TagOpen Statement TagClose

RawTemplateChar ::= SourceCharacter - TagOpen
RawTemplate ::= RawTemplateChar RawTemplate?

TemplateElement ::= TagTemplate | RawTemplate
Template ::= TemplateElement | Template TemplateElement

Program ::= Template? <EOF>