Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #21

Merged
merged 8 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

31 changes: 0 additions & 31 deletions .eslintrc.json

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
matrix:
node-version: [18.x, 19.x, 20.10.0]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- run: yarn run build
- run: npm install --include=dev
- run: npm run build
8 changes: 4 additions & 4 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "20.10.0"
- run: yarn
- run: yarn run lint
- run: npm install --include=dev
- run: npm run lint
8 changes: 4 additions & 4 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
matrix:
node-version: [18.x, 19.x, 20.10.0]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- run: yarn run test
- run: npm install --include=dev
- run: npm run test
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": false
}
893 changes: 0 additions & 893 deletions .yarn/releases/yarn-4.0.2.cjs

This file was deleted.

20 changes: 0 additions & 20 deletions .yarn/sdks/eslint/bin/eslint.js

This file was deleted.

6 changes: 0 additions & 6 deletions .yarn/sdks/eslint/package.json

This file was deleted.

5 changes: 0 additions & 5 deletions .yarn/sdks/integrations.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .yarn/sdks/prettier/index.js

This file was deleted.

6 changes: 0 additions & 6 deletions .yarn/sdks/prettier/package.json

This file was deleted.

20 changes: 0 additions & 20 deletions .yarn/sdks/typescript/bin/tsc

This file was deleted.

20 changes: 0 additions & 20 deletions .yarn/sdks/typescript/bin/tsserver

This file was deleted.

6 changes: 0 additions & 6 deletions .yarn/sdks/typescript/package.json

This file was deleted.

5 changes: 0 additions & 5 deletions .yarnrc.yml

This file was deleted.

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LiquidScript

A JavaScript and TypeScript engine for the Liquid template language.
Liquid templates for JavaScript.

[![npm version](https://img.shields.io/npm/v/liquidscript?style=flat-square)](https://www.npmjs.com/package/liquidscript)
[![tests status](https://img.shields.io/github/actions/workflow/status/jg-rp/liquidscript/tests.yaml?branch=main&label=tests&style=flat-square)](https://github.com/jg-rp/liquidscript/actions/workflows/tests.yaml)
Expand Down Expand Up @@ -66,11 +66,10 @@ Some excellent JavaScript implementations of Liquid already exist. To meet some
- Built-in math filters must handle integers and floats appropriately. For example, the `divided_by` filter should perform integer division if both arguments are integers, and regular division otherwise.
- Built-in math filters must do decimal arithmetic. See [Decimal.js dependency](#dependencies).
- Built-in filters must reject excess or otherwise invalid arguments with an error.
-

- It should be possible to extend LiquidScript (without forking) to include features commonly found in other template languages. Like template inheritance, expressions that use logical `not` and inline conditional statements, for example.

- Construct and expose a syntax tree for every parsed template, facilitating template static analysis and performance optimizations.
- Expose a syntax tree for every parsed template, facilitating template static analysis and performance optimizations.

- Offer fine-grained control of template context globals. Pin globals to an environment, template or loader.

Expand Down
7 changes: 0 additions & 7 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,5 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# API docs are generated by docusaurus-plugin-typedoc
/docs/api
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Website

This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.

### Installation

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/README_API.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# LiquidScript API Documentation

Welcome to the API documentation for LiquidScript. Also see the [Getting Started](introduction/getting-started.mdx) guide for an introduction to LiquidScript, and the [introduction to Liquid](language/introduction.md), the [tag reference](/language/tags) and the [filter reference](/language/filters) for how to write Liquid templates.
Welcome to the API documentation for LiquidScript. Also see the [Getting Started](/introduction/getting-started) guide for an introduction to LiquidScript, and the [introduction to Liquid](/language/introduction), the [tag reference](/language/tags) and the [filter reference](/language/filters) for how to write Liquid templates.

## API Quick Links

- [Environment](/api/classes/Environment)
- [Environment Options](/api/modules#environmentoptions)
- [Environment Options](/api/type-aliases/EnvironmentOptions)
- [Template](/api/classes/Template)
- [Template Loaders](/api/classes/Loader)
12 changes: 6 additions & 6 deletions docs/docs/guides/custom-filters.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ delete env.filters.base64_decode;

## Filter Context

Filter functions are applied with their `this` value set to a [`FilterContext`](../api/modules.md#filtercontext), giving filters access to the current environment and render context.
Filter functions are applied with their `this` value set to a [`FilterContext`](../api/type-aliases/FilterContext.md), giving filters access to the current environment and render context.

This example resolves the name `"handle"` in the scope of the current render context, then uses the result as part of the filter's return value. We also reference the `autoEscape` option set on the active environment.

Expand Down Expand Up @@ -124,19 +124,19 @@ env.addFilter("link_to_tag", LinkToTag);

### Keyword Arguments and Options

The [`FilterContext`](../api/modules.md#filtercontext) also includes any keyword arguments passed to the filter. These are available as `this.options`. The [`default`](../language/filters.md#default) filter is the only built-in filter to use a keyword argument. For example, `{{ user.name | default: 'anonymous', allow_false: false }}`
The [`FilterContext`](../api/type-aliases/FilterContext.md) also includes any keyword arguments passed to the filter. These are available as `this.options`. The [`default`](../language/filters.md#default) filter is the only built-in filter to use a keyword argument. For example, `{{ user.name | default: 'anonymous', allow_false: false }}`

:::info
In Liquid, keyword arguments can appear in any order, even before and inbetween positional arguments. It is because of this, and the desire to allow filters with [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters), that LiquidScript puts options in the filter context object instead of the last argument of the filter function.
:::

## Liquid Numbers and Arithmetic

Unlike JavaScript, Liquid has distinct integer and float number types. To maintain compatibility with the reference implementation of Liquid, LiquidScript defines an [`Integer`](../api/classes/Integer.md) type, a [`Float`](../api/classes/Float.md) type and [utility functions](../api/modules.md#parsenumbert) for converting to these types.
Unlike JavaScript, Liquid has distinct integer and float number types. To maintain compatibility with the reference implementation of Liquid, LiquidScript defines an [`Integer`](../api/classes/Integer.md) type, a [`Float`](../api/classes/Float.md) type and [utility functions](../api/functions/parseNumberT.md) for converting to these types.

Both `Integer` and `Float` export methods for performing decimal arithmetic, as opposed to JavaScript's usual floating point arithmetic.

When writing custom filters that expect numbers as inputs, you should be prepared to handle JavaScript primitive numbers **and** Liquid numbers. All built-in math filters convert their arguments to Liquid's [`NumberT`](../api/modules.md#numbert) type on input, exclusively use methods of those types for arithmetic, and return a `NumberT` too.
When writing custom filters that expect numbers as inputs, you should be prepared to handle JavaScript primitive numbers **and** Liquid numbers. All built-in math filters convert their arguments to Liquid's [`NumberT`](../api/functions/parseNumberT.md) type on input, exclusively use methods of those types for arithmetic, and return a `NumberT` too.

To illustrate, here's the implementation of the [`plus`](../language/filters.md#plus) filter. It makes no assumptions about the type of its arguments and both arguments default to zero if they can't be converted to a number.

Expand Down Expand Up @@ -248,10 +248,10 @@ function append(

All filters built in to Liquid throw a [`LiquidFilterArgumentError`](../api/classes/LiquidFilterArgumentError.md) if a required argument is missing or too many arguments are provided.

When writing custom filters, if you want to be consistent with those built-in filters, you can use [`checkArguments`](../api/modules.md#checkarguments) to throw an error with a suitable message.
When writing custom filters, if you want to be consistent with those built-in filters, you can use [`checkArguments`](../api/functions/checkArguments.md) to throw an error with a suitable message.

## Undefined vs undefined

LiquidScript defines an [`Undefined`](../introduction/undefined.md) type, which is distinct from JavaScript's primitive `undefined` value. With [`LaxUndefined`](../api/classes/LaxUndefined.md), `Undefined` objects will be passed to filter functions if they are "called" with arguments that can not be resolved by the active render context.

If a filter function needs to detect `Undefined` and `undefined` arguments, it can use [`object.isUndefined()`](../api/namespaces/object.md#isundefined).
If a filter function needs to detect `Undefined` and `undefined` arguments, it can use [`object.isUndefined()`](../api/namespaces/object/functions/isUndefined.md).
2 changes: 1 addition & 1 deletion docs/docs/guides/custom-loaders.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import TabItem from "@theme/TabItem";

[Template loaders](../introduction/loading-templates.md#built-in-template-loaders) are responsible for finding a template's source text given a name or identifier. You might want to write a custom template loader to read templates from a database, narrow the template search space for a specific user, or add extra context data to a template, for example.

Write a custom template loader by extending the [`Loader`](../api/classes/Loader.md) base class and implementing its [`getSource()`](../api/classes/Loader.md#getsource) and [`getSourceSync()`](../api/classes/Loader.md#getsourcesync) methods. Then configure an [`Environment`](../api/classes/Environment.md) to use your loader with the [`loader`](../api/modules.md#environmentoptions) option.
Write a custom template loader by extending the [`Loader`](../api/classes/Loader.md) base class and implementing its [`getSource()`](../api/classes/Loader.md#getsource) and [`getSourceSync()`](../api/classes/Loader.md#getsourcesync) methods. Then configure an [`Environment`](../api/classes/Environment.md) to use your loader with the [`loader`](../api/type-aliases/EnvironmentOptions.md#loader) option.

## Example Map Loader

Expand Down
6 changes: 3 additions & 3 deletions docs/docs/guides/custom-tags.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ We use [class syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re

### Example Tag

A [`Tag`](../api/interfaces/Tag.md) is free to parse its expression any way it chooses. Built in tags use regular expressions to [generate](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator) a [stream of tokens](../api/classes/expressions.ExpressionTokenStream.md), then step through those tokens yielding [`Expression`](../api/interfaces/Expression.md) objects.
A [`Tag`](../api/interfaces/Tag.md) is free to parse its expression any way it chooses. Built in tags use regular expressions to [generate](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator) a [stream of tokens](../api/namespaces/expressions/classes/ExpressionTokenStream.md), then step through those tokens yielding [`Expression`](../api/interfaces/Expression.md) objects.

:::info
Despite their names, `ExpressionTokenStream`, `TokenStream` and `RenderStream` do not implement a Node.js stream or a web stream.
Expand Down Expand Up @@ -103,9 +103,9 @@ type Arguments = {
</TabItem>
</Tabs>

The [`parse()`](../api/interfaces/Tag.md#parse) method of a `Tag` object receives a [`TokenStream`](../api/classes/tokens.TemplateTokenStream.md) and a reference to the active [`Environment`](../api/classes/Environment.md). This stream of [tokens](../api/namespaces/tokens.md#variables) includes template literals, output statements, tags and unparsed tag expressions.
The [`parse()`](../api/interfaces/Tag.md#parse) method of a `Tag` object receives a [`TokenStream`](../api/namespaces/tokens/interfaces/TokenStream.md) and a reference to the active [`Environment`](../api/classes/Environment.md). This stream of [tokens](/api/namespaces/tokens#variables) includes template literals, output statements, tags and unparsed tag expressions.

The current token in the stream will always be of the type [`TOKEN_TAG`](../api/namespaces/tokens.md#token_tag), representing the start of the tag we're parsing. By convention, this token is used to populate the `token` property of the associated `Node` object. If the tag has an expression (anything after the tag's name), it will immediately follow the `TOKEN_TAG` in the stream as a [`TOKEN_EXPRESSION`](../api/namespaces/tokens.md#token_expression). In the example bellow we use [`TokenStream.expect()`](../api/interfaces/tokens.TokenStream.md#expect) to confirm that an expression was provided.
The current token in the stream will always be of the type [`TOKEN_TAG`](../api/namespaces/tokens/variables/TOKEN_TAG.md), representing the start of the tag we're parsing. By convention, this token is used to populate the `token` property of the associated `Node` object. If the tag has an expression (anything after the tag's name), it will immediately follow the `TOKEN_TAG` in the stream as a [`TOKEN_EXPRESSION`](../api/namespaces/tokens/variables/TOKEN_EXPRESSION). In the example bellow we use [`TokenStream.expect()`](../api/namespaces/tokens/interfaces/TokenStream.md#expect) to confirm that an expression was provided.

We use [`parseBlock()`](../api/interfaces/Parser.md#parseblock) from the active environment to parse our `with` tag's block, which could contain any number of other tags and output statements. Every block tag is expected to leave the stream with it's "end" tag as the current token.

Expand Down
Loading