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

Replace Travis CI with GitHub Actions (for v4) #760

Open
wants to merge 29 commits into
base: version-4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a4770b8
docs: add missing closing parenthesis in async option description (#766)
adnantabda Jul 23, 2024
f0a06fa
Begin work on version 4
mde Apr 28, 2024
f486d8c
Compile task, updated linting
mde May 1, 2024
fb4cf55
Updated lint config
mde May 1, 2024
1311dac
Get tests working
mde May 1, 2024
1c89b53
Get build working
mde May 1, 2024
2292fef
Replace `let` in code-generation strings for CJS
mde May 1, 2024
71b406c
Support Nodes back to 0.12
mde May 1, 2024
306c74f
Removed old doc file
mde May 1, 2024
9665014
Updated JSDoc path
mde May 1, 2024
dbf2552
Updated docs
mde May 1, 2024
e1f6df4
Build before test again
mde May 1, 2024
304f438
Updated deps
mde May 1, 2024
306698c
Updated docs
mde May 1, 2024
d533c4a
Updated docs
mde May 1, 2024
3c3136c
Updated docs
mde May 1, 2024
59fe5f5
testOnly task for running tests without building
mde May 1, 2024
3f81721
Cleaner keyword replacement
mde May 1, 2024
66db8bd
Namespace Node builtins
mde May 2, 2024
a40aa4c
Updated Jake version
mde May 3, 2024
15d62ba
Bake in version string during packaging
mde May 3, 2024
10eb8bd
Removed unused import
mde May 3, 2024
a09e12e
Removed version and name
mde May 4, 2024
86eb76f
Replace Travis CI with GitHub Actions
phanect May 9, 2024
3a6c1fc
Build on CI process
phanect May 10, 2024
e8fadd4
Update `engines` in package.json
phanect May 9, 2024
4bd8b4f
Remove unnecessary `npx` in npm scripts
phanect May 10, 2024
80d6ed9
Update package-lock.json
phanect May 9, 2024
c332dc7
Trigger CI on `version-4` branch and PRs to it
phanect May 10, 2024
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
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: GitHub Actions

on:
pull_request:
branches:
- main
- version-4 # Delete this after EJS v4 is released
push:
branches:
- main
- version-4 # Delete this after EJS v4 is released

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version:
- 18
- 20
- 21
- 22
steps:
- uses: actions/checkout@v4
- name: Use Node.js v${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm

- run: npm ci
- run: npm run build
- run: npm test
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

46 changes: 34 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ app.get('/', (req, res) => {
$ npm install ejs
```

### Import or require

Supports both CommonJS and ES Modules.

```javascript
import ejs from 'ejs';
// Or
const ejs = require('ejs');
```

### Compatibility

Server: CommonJS approach (`require`) supports Node versions at least
back to v0.12, likely older versions too. ES Modules approach (`import`)
requires a Node version that supports ESM.

CLI: Requires Node v8 or newer.

Browser: EJS supports all modern browsers, but is very likely to work even
in very, very old browsers. Your mileage may vary.

## Features

* Control flow with `<% %>`
Expand Down Expand Up @@ -51,7 +72,7 @@ Try EJS online at: https://ionicabizau.github.io/ejs-playground/.
## Basic usage

```javascript
let template = ejs.compile(str, options);
const template = ejs.compile(str, options);
template(data);
// => Rendered HTML string

Expand All @@ -70,7 +91,7 @@ add an option with the same name as one of your data object's properties.
Therefore, we do not recommend using this shortcut.

### Important
You should never give end-users unfettered access to the EJS render method, If you do so you are using EJS in an inherently un-secure way.
You should never give end-users unfettered access to the EJS render method, If you do so you are using EJS in an inherently un-secure way.

### Options

Expand Down Expand Up @@ -106,7 +127,7 @@ You should never give end-users unfettered access to the EJS render method, If y
- `outputFunctionName` Set to a string (e.g., 'echo' or 'print') for a function to print
output inside scriptlet tags.
- `async` When `true`, EJS will use an async function for rendering. (Depends
on async/await support in the JS runtime.
on async/await support in the JS runtime).
- `includer` Custom function to handle EJS includes, receives `(originalPath, parsedPath)`
parameters, where `originalPath` is the path in include as-is and `parsedPath` is the
previously resolved path. Should return an object `{ filename, template }`,
Expand Down Expand Up @@ -167,8 +188,8 @@ not supported in v3.0+.
Custom delimiters can be applied on a per-template basis, or globally:

```javascript
let ejs = require('ejs'),
users = ['geddy', 'neil', 'alex'];
import ejs from 'ejs';
const users = ['geddy', 'neil', 'alex'];

// Just one template
ejs.render('<p>[?= users.join(" | "); ?]</p>', {users: users}, {delimiter: '?', openDelimiter: '[', closeDelimiter: ']'});
Expand All @@ -189,9 +210,10 @@ functions used to render templates. It's easy to plug in LRU caching using
Node's `lru-cache` library:

```javascript
let ejs = require('ejs'),
LRU = require('lru-cache');
ejs.cache = LRU(100); // LRU cache with 100-item limit
import ejs from 'ejs';
import { LRUCache } from 'lru-cache';

ejs.cache = LRUCache({max: 100}); // LRU cache with 100-item limit
```

If you want to clear the EJS cache, call `ejs.clearCache`. If you're using the
Expand All @@ -203,8 +225,9 @@ of the LRU.
The default file loader is `fs.readFileSync`, if you want to customize it, you can set ejs.fileLoader.

```javascript
let ejs = require('ejs');
let myFileLoad = function (filePath) {
import ejs from 'ejs';

const myFileLoad = function (filePath) {
return 'myFileLoad: ' + fs.readFileSync(filePath);
};

Expand All @@ -218,7 +241,6 @@ With this feature, you can preprocess the template before reading it.
EJS does not specifically support blocks, but layouts can be implemented by
including headers and footers, like so:


```ejs
<%- include('header') -%>
<h1>
Expand All @@ -234,7 +256,7 @@ including headers and footers, like so:

Go to the [Latest Release](https://github.com/mde/ejs/releases/latest), download
`./ejs.js` or `./ejs.min.js`. Alternately, you can compile it yourself by cloning
the repository and running `jake build` (or `$(npm bin)/jake build` if jake is
the repository and running `jake build` (or `npx jake build` if jake is
not installed globally).

Include one of these files on your page, and `ejs` should be available globally.
Expand Down
4 changes: 2 additions & 2 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ let program = require('jake').program;
delete global.jake; // NO NOT WANT
program.setTaskNames = function (n) { this.taskNames = n; };

let ejs = require('../lib/ejs');
let { hyphenToCamel } = require('../lib/utils');
let ejs = require('../lib/cjs/ejs');
let { hyphenToCamel } = require('../lib/cjs/utils');
let fs = require('fs');
let args = process.argv.slice(2);
let usage = fs.readFileSync(`${__dirname}/../usage.txt`).toString();
Expand Down
Loading