-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55805ee
commit bb97b27
Showing
8 changed files
with
176 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
* text=auto | ||
*.js text eol=lf | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: CI | ||
on: | ||
- push | ||
- pull_request | ||
jobs: | ||
test: | ||
name: Node.js ${{ matrix.node-version }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: | ||
- 20 | ||
- 18 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm test |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,19 @@ | ||
'use strict'; | ||
const PluginError = require('plugin-error'); | ||
const through = require('through2'); | ||
const _ = require('lodash'); | ||
const Buffer = require('safe-buffer').Buffer; | ||
|
||
const template = _.template; | ||
import {Buffer} from 'node:buffer'; | ||
import _ from 'lodash'; | ||
import {gulpPlugin} from 'gulp-plugin-extras'; | ||
|
||
function compile(options, data, render) { | ||
return through.obj(function (file, enc, cb) { | ||
if (file.isNull()) { | ||
cb(null, file); | ||
return; | ||
} | ||
|
||
if (file.isStream()) { | ||
cb(new PluginError('gulp-template', 'Streaming not supported')); | ||
return; | ||
} | ||
|
||
try { | ||
const tpl = template(file.contents.toString(), options); | ||
file.contents = Buffer.from(render ? tpl(_.merge({}, file.data, data)) : tpl.toString()); | ||
this.push(file); | ||
} catch (err) { | ||
this.emit('error', new PluginError('gulp-template', err, {fileName: file.path})); | ||
} | ||
|
||
cb(); | ||
return gulpPlugin('gulp-template', file => { | ||
const template = _.template(file.contents.toString(), options); | ||
file.contents = Buffer.from(render ? template(_.merge({}, file.data, data)) : template.toString()); | ||
return file; | ||
}); | ||
} | ||
|
||
module.exports = (data, options) => compile(options, data, true); | ||
module.exports.precompile = options => compile(options); | ||
export default function gulpTemplate(data, options) { | ||
return compile(options, data, true); | ||
} | ||
|
||
export function precompile(options) { | ||
return compile(options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
MIT License | ||
|
||
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com) | ||
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,19 @@ | |
"description": "Render/precompile Lodash/Underscore templates", | ||
"license": "MIT", | ||
"repository": "sindresorhus/gulp-template", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "[email protected]", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=4" | ||
"node": ">=18" | ||
}, | ||
"scripts": { | ||
"test": "xo && mocha" | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
|
@@ -30,15 +33,21 @@ | |
"precompile" | ||
], | ||
"dependencies": { | ||
"lodash": "^4.8.2", | ||
"plugin-error": "^0.1.2", | ||
"safe-buffer": "^5.1.1", | ||
"through2": "^2.0.0" | ||
"gulp-plugin-extras": "^0.2.2", | ||
"lodash": "^4.17.21" | ||
}, | ||
"devDependencies": { | ||
"gulp-data": "^1.0.2", | ||
"mocha": "*", | ||
"vinyl": "^2.1.0", | ||
"xo": "*" | ||
"ava": "^5.3.1", | ||
"gulp-data": "^1.3.1", | ||
"vinyl": "^3.0.0", | ||
"xo": "^0.56.0" | ||
}, | ||
"peerDependencies": { | ||
"gulp": ">=4" | ||
}, | ||
"peerDependenciesMeta": { | ||
"gulp": { | ||
"optional": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.