v2.0.0
This commit is contained in:
parent
b0767cb34b
commit
96e24c8e19
|
@ -1,7 +1,7 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
trim_trailing_whitespace = true
|
||||
|
|
|
@ -53,6 +53,7 @@ Temporary Items
|
|||
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
|
@ -84,12 +85,15 @@ $RECYCLE.BIN/
|
|||
*.rar
|
||||
*.zip
|
||||
*.gz
|
||||
*.gzip
|
||||
*.tgz
|
||||
*.bzip
|
||||
*.bzip2
|
||||
*.bz2
|
||||
*.xz
|
||||
*.lzma
|
||||
*.cab
|
||||
*.xar
|
||||
|
||||
# Packing-only formats
|
||||
*.iso
|
||||
|
@ -105,6 +109,7 @@ $RECYCLE.BIN/
|
|||
*.msi
|
||||
*.msm
|
||||
*.msp
|
||||
*.txz
|
||||
|
||||
# https://github.com/github/gitignore/blob/master/Global/Backup.gitignore
|
||||
|
||||
|
@ -114,88 +119,22 @@ $RECYCLE.BIN/
|
|||
*.orig
|
||||
*.tmp
|
||||
|
||||
# https://github.com/github/gitignore/blob/master/Node.gitignore
|
||||
# Node
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
node_modules
|
||||
npm-*.log
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
# Yarn
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
yarn-*.log
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
# Composer
|
||||
|
||||
vendor
|
||||
|
|
17
.prettierrc
17
.prettierrc
|
@ -1,15 +1,6 @@
|
|||
{
|
||||
"printWidth": 120,
|
||||
"tabWidth": 4,
|
||||
"useTabs": true,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"quoteProps": "as-needed",
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": false,
|
||||
"arrowParens": "always",
|
||||
"proseWrap": "preserve",
|
||||
"htmlWhitespaceSensitivity": "css",
|
||||
"vueIndentScriptAndStyle": false,
|
||||
"endOfLine": "lf"
|
||||
"printWidth": 120,
|
||||
"tabWidth": 4,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,7 @@
|
|||
nodeLinker: node-modules
|
||||
|
||||
plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
||||
spec: "@yarnpkg/plugin-interactive-tools"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-3.1.1.cjs
|
64
README.md
64
README.md
|
@ -28,38 +28,38 @@ const nunjucksTemplate = `
|
|||
|
||||
```js
|
||||
[
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: [/mocks\.js$/],
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
cacheDirectory: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /mocks\.js$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
compact: false,
|
||||
plugins: [
|
||||
[
|
||||
'@advdominion/babel-plugin-nunjucks',
|
||||
{
|
||||
templatesFolder: 'src/templates/',
|
||||
varNames: ['nunjucksTemplate'],
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: [/mocks\.js$/],
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
cacheDirectory: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /mocks\.js$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
compact: false,
|
||||
plugins: [
|
||||
[
|
||||
'@advdominion/babel-plugin-nunjucks',
|
||||
{
|
||||
templatesFolder: 'src/templates/',
|
||||
varNames: ['nunjucksTemplate'],
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
|
|
42
index.js
42
index.js
|
@ -1,23 +1,23 @@
|
|||
const nunjucks = require('nunjucks');
|
||||
import nunjucks from 'nunjucks';
|
||||
|
||||
module.exports = ({types: t}) => {
|
||||
return {
|
||||
visitor: {
|
||||
Identifier(path, state) {
|
||||
for (let i = 0; i < state.opts.varNames.length; i += 1) {
|
||||
if (
|
||||
path.parentPath.type === 'VariableDeclarator' &&
|
||||
path.isIdentifier({name: state.opts.varNames[i]})
|
||||
) {
|
||||
const templatesFolder = state.opts.templatesFolder;
|
||||
const value = path.parentPath.get('init').node.quasis[0].value.raw;
|
||||
const env = new nunjucks.Environment(new nunjucks.FileSystemLoader(templatesFolder));
|
||||
const render = env.renderString(value);
|
||||
path.parentPath.get('init').node.quasis = [t.templateElement({cooked: render, raw: render})];
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
export default ({types: t}) => {
|
||||
return {
|
||||
visitor: {
|
||||
Identifier(path, state) {
|
||||
for (let i = 0; i < state.opts.varNames.length; i += 1) {
|
||||
if (
|
||||
path.parentPath.type === 'VariableDeclarator' &&
|
||||
path.isIdentifier({name: state.opts.varNames[i]})
|
||||
) {
|
||||
const templatesFolder = state.opts.templatesFolder;
|
||||
const value = path.parentPath.get('init').node.quasis[0].value.raw;
|
||||
const env = new nunjucks.Environment(new nunjucks.FileSystemLoader(templatesFolder));
|
||||
const render = env.renderString(value);
|
||||
path.parentPath.get('init').node.quasis = [t.templateElement({cooked: render, raw: render})];
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
33
package.json
33
package.json
|
@ -1,16 +1,21 @@
|
|||
{
|
||||
"name": "@advdominion/babel-plugin-nunjucks",
|
||||
"version": "1.10.0",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://bitbucket.org/advdominion/babel-plugin-nunjucks"
|
||||
},
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@babel/core": "7.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"nunjucks": "^3.2.3"
|
||||
}
|
||||
"name": "@advdominion/babel-plugin-nunjucks",
|
||||
"version": "2.0.0",
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": "^16.0.0"
|
||||
},
|
||||
"packageManager": "yarn@3.1.1",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://bitbucket.org/advdominion/babel-plugin-nunjucks"
|
||||
},
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@babel/core": "7.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"nunjucks": "^3.2.3"
|
||||
}
|
||||
}
|
||||
|
|
76
yarn.lock
76
yarn.lock
|
@ -1,27 +1,55 @@
|
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
# This file is generated by running "yarn install" inside your project.
|
||||
# Manual changes might be lost - proceed with caution!
|
||||
|
||||
__metadata:
|
||||
version: 5
|
||||
cacheKey: 8
|
||||
|
||||
a-sync-waterfall@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/a-sync-waterfall/-/a-sync-waterfall-1.0.1.tgz#75b6b6aa72598b497a125e7a2770f14f4c8a1fa7"
|
||||
integrity sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA==
|
||||
|
||||
asap@^2.0.3:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
|
||||
integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=
|
||||
|
||||
commander@^5.1.0:
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae"
|
||||
integrity sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==
|
||||
|
||||
nunjucks@^3.2.3:
|
||||
version "3.2.3"
|
||||
resolved "https://registry.yarnpkg.com/nunjucks/-/nunjucks-3.2.3.tgz#1b33615247290e94e28263b5d855ece765648a31"
|
||||
integrity sha512-psb6xjLj47+fE76JdZwskvwG4MYsQKXUtMsPh6U0YMvmyjRtKRFcxnlXGWglNybtNTNVmGdp94K62/+NjF5FDQ==
|
||||
"@advdominion/babel-plugin-nunjucks@workspace:.":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@advdominion/babel-plugin-nunjucks@workspace:."
|
||||
dependencies:
|
||||
a-sync-waterfall "^1.0.0"
|
||||
asap "^2.0.3"
|
||||
commander "^5.1.0"
|
||||
nunjucks: ^3.2.3
|
||||
peerDependencies:
|
||||
"@babel/core": 7.x
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"a-sync-waterfall@npm:^1.0.0":
|
||||
version: 1.0.1
|
||||
resolution: "a-sync-waterfall@npm:1.0.1"
|
||||
checksum: 534948b50d6787c2dd5b7e89179b30c0fd96ac80a662d0f92eaa568cfffb36f1eea4aa720e3a21572d8b5f8686940954ac9d8c7667bcc719c1317ae3bdf86fe0
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"asap@npm:^2.0.3":
|
||||
version: 2.0.6
|
||||
resolution: "asap@npm:2.0.6"
|
||||
checksum: b296c92c4b969e973260e47523207cd5769abd27c245a68c26dc7a0fe8053c55bb04360237cb51cab1df52be939da77150ace99ad331fb7fb13b3423ed73ff3d
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"commander@npm:^5.1.0":
|
||||
version: 5.1.0
|
||||
resolution: "commander@npm:5.1.0"
|
||||
checksum: 0b7fec1712fbcc6230fcb161d8d73b4730fa91a21dc089515489402ad78810547683f058e2a9835929c212fead1d6a6ade70db28bbb03edbc2829a9ab7d69447
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"nunjucks@npm:^3.2.3":
|
||||
version: 3.2.3
|
||||
resolution: "nunjucks@npm:3.2.3"
|
||||
dependencies:
|
||||
a-sync-waterfall: ^1.0.0
|
||||
asap: ^2.0.3
|
||||
commander: ^5.1.0
|
||||
peerDependencies:
|
||||
chokidar: ^3.3.0
|
||||
peerDependenciesMeta:
|
||||
chokidar:
|
||||
optional: true
|
||||
bin:
|
||||
nunjucks-precompile: bin/precompile
|
||||
checksum: 9d0125acf917166675af2d9b5d525b6d3edaba68ec6f8c92edee8ad05140cfa8aef12feb46f4c3da52ed2836cadfb9d26fbf1fa9d9be6bef4660d03ce1e89dbe
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
|
Loading…
Reference in New Issue