Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
0ab254e4ed | |||
185b7a38d5 | |||
7ab6922eed | |||
31bf5f7486 | |||
78d4df7082 | |||
74d2d980a5 | |||
49aa80aca8 | |||
b382256cc7 | |||
97400fa501 | |||
914a8eafce | |||
7299b3a9c6 | |||
cfd257d359 | |||
203ea05f67 | |||
f00a11bf9b | |||
7b0f2ab8d6 | |||
3ef9388979 | |||
1d35da50cd | |||
f5b86154db | |||
7474d208e4 | |||
74f4026c74 | |||
3808e4168f | |||
084bee68af | |||
9f6b67fa4e |
20
.gitignore
vendored
20
.gitignore
vendored
@ -1,6 +1,20 @@
|
||||
node_modules/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
test/testresult/
|
||||
.nogit/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
140
.gitlab-ci.yml
140
.gitlab-ci.yml
@ -1,126 +1,122 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
before_script:
|
||||
- npm install -g @shipzone/npmci
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
snyk:
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci command npm install -g snyk
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install legacy
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
testSTABLE:
|
||||
- docker
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
image: docker:stable
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SOURCE_CODE="$PWD"
|
||||
--volume "$PWD":/code
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||
artifacts:
|
||||
paths: [codeclimate.json]
|
||||
- npmci command npm install -g typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci node install stable
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
- npmci command npm run buildDocs
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
@ -128,15 +124,5 @@ pages:
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
|
||||
windowsCompatibility:
|
||||
image: stefanscherer/node-windows:10-build-tools
|
||||
stage: metadata
|
||||
script:
|
||||
- npm install & npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- windows
|
||||
- public
|
||||
allow_failure: true
|
||||
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/npmextra.json"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"npmci": {
|
||||
"type": "object",
|
||||
"description": "settings for npmci"
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
47
README.md
47
README.md
@ -1,47 +0,0 @@
|
||||
# smarthbs
|
||||
|
||||
handlebars with better fs support
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/smarthbs)
|
||||
[](https://GitLab.com/pushrocks/smarthbs)
|
||||
[](https://github.com/pushrocks/smarthbs)
|
||||
[](https://pushrocks.gitlab.io/smarthbs/)
|
||||
|
||||
## Status for master
|
||||
|
||||
[](https://GitLab.com/pushrocks/smarthbs/commits/master)
|
||||
[](https://GitLab.com/pushrocks/smarthbs/commits/master)
|
||||
[](https://www.npmjs.com/package/smarthbs)
|
||||
[](https://david-dm.org/pushrocks/smarthbs)
|
||||
[](https://www.bithound.io/github/pushrocks/smarthbs/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smarthbs)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> Note: Why did we decide against a class based architecture?
|
||||
> Easy: handlebars.js is already pretty determined how things are handled internally, namely a global partial template registry
|
||||
> It doesn't make sense to then introduce a scoped partial template approach.
|
||||
|
||||
```javascript
|
||||
import * as smarthbs from 'smarthbs';
|
||||
|
||||
// read all .hbs files in a directory and any child directories and use relative path as partial string identifier
|
||||
smarthbs.registerPartialDir(testPartialDir);
|
||||
|
||||
// read all .hbs files in a particular directory and level, output them to a destination and specify a .json file to read any referenced data
|
||||
smarthbs.compileDirectory(testHbsDir, testResultDir, 'data.json');
|
||||
```
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[](https://push.rocks)
|
@ -1,47 +0,0 @@
|
||||
# smarthbs
|
||||
|
||||
handlebars with better fs support
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/smarthbs)
|
||||
[](https://GitLab.com/pushrocks/smarthbs)
|
||||
[](https://github.com/pushrocks/smarthbs)
|
||||
[](https://pushrocks.gitlab.io/smarthbs/)
|
||||
|
||||
## Status for master
|
||||
|
||||
[](https://GitLab.com/pushrocks/smarthbs/commits/master)
|
||||
[](https://GitLab.com/pushrocks/smarthbs/commits/master)
|
||||
[](https://www.npmjs.com/package/smarthbs)
|
||||
[](https://david-dm.org/pushrocks/smarthbs)
|
||||
[](https://www.bithound.io/github/pushrocks/smarthbs/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smarthbs)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> Note: Why did we decide against a class based architecture?
|
||||
> Easy: handlebars.js is already pretty determined how things are handled internally, namely a global partial template registry
|
||||
> It doesn't make sense to then introduce a scoped partial template approach.
|
||||
|
||||
```javascript
|
||||
import * as smarthbs from 'smarthbs';
|
||||
|
||||
// read all .hbs files in a directory and any child directories and use relative path as partial string identifier
|
||||
smarthbs.registerPartialDir(testPartialDir);
|
||||
|
||||
// read all .hbs files in a particular directory and level, output them to a destination and specify a .json file to read any referenced data
|
||||
smarthbs.compileDirectory(testHbsDir, testResultDir, 'data.json');
|
||||
```
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[](https://push.rocks)
|
@ -2,5 +2,16 @@
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"gitrepo": "smarthbs",
|
||||
"description": "handlebars with better fs support",
|
||||
"npmPackagename": "@pushrocks/smarthbs",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1009
package-lock.json
generated
1009
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
46
package.json
46
package.json
@ -1,13 +1,14 @@
|
||||
{
|
||||
"name": "@pushrocks/smarthbs",
|
||||
"version": "2.0.0",
|
||||
"version": "3.0.2",
|
||||
"private": false,
|
||||
"description": "handlebars with better fs support",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)"
|
||||
"build": "(tsbuild --allowimplicitany)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -23,18 +24,31 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pkunz/smarthbs#README",
|
||||
"dependencies": {
|
||||
"@pushrocks/smartfile": "^6.0.8",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@types/handlebars": "^4.0.39",
|
||||
"@types/lodash": "^4.14.116",
|
||||
"handlebars": "^4.0.11",
|
||||
"lodash": "^4.17.10"
|
||||
"@pushrocks/smartfile": "^10.0.2",
|
||||
"@pushrocks/smartpath": "^5.0.5",
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"handlebars": "^4.7.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tsrun": "^1.1.12",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@pushrocks/tapbundle": "^3.0.5",
|
||||
"@types/node": "^10.9.2"
|
||||
}
|
||||
"@gitzone/tsbuild": "^2.1.63",
|
||||
"@gitzone/tsrun": "^1.2.37",
|
||||
"@gitzone/tstest": "^1.0.72",
|
||||
"@pushrocks/tapbundle": "^5.0.4",
|
||||
"@types/node": "^18.0.6"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
4393
pnpm-lock.yaml
generated
Normal file
4393
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
52
readme.md
Normal file
52
readme.md
Normal file
@ -0,0 +1,52 @@
|
||||
# @pushrocks/smarthbs
|
||||
handlebars with better fs support
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smarthbs)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smarthbs)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/smarthbs)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smarthbs/)
|
||||
|
||||
## Status for master
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
> Note: Why did we decide against a class based architecture?
|
||||
> Easy: handlebars.js is already pretty determined how things are handled internally, namely a global partial template registry
|
||||
> It doesn't make sense to then introduce a scoped partial template approach.
|
||||
|
||||
```javascript
|
||||
import * as smarthbs from 'smarthbs';
|
||||
|
||||
// read all .hbs files in a directory and any child directories and use relative path as partial string identifier
|
||||
smarthbs.registerPartialDir(testPartialDir);
|
||||
|
||||
// read all .hbs files in a particular directory and level, output them to a destination and specify a .json file to read any referenced data
|
||||
smarthbs.compileDirectory(testHbsDir, testResultDir, 'data.json');
|
||||
```
|
||||
|
||||
|
||||
## Contribution
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
30
test/test.ts
30
test/test.ts
@ -1,24 +1,28 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smarthbs from '../ts/index';
|
||||
import * as smarthbs from '../ts/index.js';
|
||||
|
||||
import * as smartpath from '@pushrocks/smartpath';
|
||||
import * as path from 'path';
|
||||
|
||||
let testHbsDir = path.join(__dirname, 'hbs_testfiles');
|
||||
let testPartialDir = path.join(testHbsDir, 'partials');
|
||||
let testResultDir = path.join(__dirname, 'testresult');
|
||||
const dirname = smartpath.get.dirnameFromImportMetaUrl(import.meta.url);
|
||||
|
||||
let hbs_testfilesDir = path.join(dirname, 'hbs_testfiles');
|
||||
let testPartialDir = path.join(hbs_testfilesDir, 'partials');
|
||||
let testResultDir = path.join(dirname, 'testresult');
|
||||
|
||||
tap.test('smarthbs -> should create partials', async () => {
|
||||
await smarthbs.registerPartialDir(testPartialDir);
|
||||
});
|
||||
|
||||
tap.test('smarthbs -> should compile a directory', async () => {
|
||||
smarthbs.compileDirectory(testHbsDir, testResultDir, 'data.json');
|
||||
smarthbs.compileDirectory(hbs_testfilesDir, testResultDir, 'data.json');
|
||||
});
|
||||
|
||||
tap.test('', async () => {
|
||||
let templateString = '{{{firstVar}}} {{secondVar}}';
|
||||
let templateVars = await smarthbs.findVarsInHbsString(templateString);
|
||||
expect(templateVars).to.include('firstVar');
|
||||
expect(templateVars).to.include('secondVar');
|
||||
expect(templateVars).toContain('firstVar');
|
||||
expect(templateVars).toContain('secondVar');
|
||||
});
|
||||
|
||||
tap.test('', async () => {
|
||||
@ -29,12 +33,14 @@ tap.test('', async () => {
|
||||
secondVar: 'hello',
|
||||
fourthVar: {
|
||||
otherKey: {
|
||||
nextKey: 'wow'
|
||||
}
|
||||
}
|
||||
nextKey: 'wow',
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(missingVars).to.contain('thirdVar', 'fourthVar.someKey');
|
||||
expect(missingVars).to.not.contain('secondVar', 'fourthVar.otherKey.nextKey');
|
||||
expect(missingVars).toContain('thirdVar');
|
||||
expect(missingVars).toContain('fourthVar.someKey');
|
||||
expect(missingVars).not.toContain('secondVar');
|
||||
expect(missingVars).not.toContain('fourthVar.otherKey.nextKey');
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
1
test/testresult/index.html
Normal file
1
test/testresult/index.html
Normal file
@ -0,0 +1 @@
|
||||
<head></head>analyzed
|
1
test/testresult/index2.html
Normal file
1
test/testresult/index2.html
Normal file
@ -0,0 +1 @@
|
||||
A second hbs file!
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smarthbs',
|
||||
version: '3.0.2',
|
||||
description: 'handlebars with better fs support'
|
||||
}
|
14
ts/index.ts
14
ts/index.ts
@ -1,10 +1,10 @@
|
||||
import * as plugins from './smarthbs.plugins';
|
||||
import * as plugins from './smarthbs.plugins.js';
|
||||
export type TTemplateStringType = 'filePath' | 'code';
|
||||
|
||||
export let handlebars = plugins.handlebars;
|
||||
export * from './smarthbs.compile';
|
||||
import './smarthbs.helpers';
|
||||
export * from './smarthbs.partials';
|
||||
export * from './smarthbs.template';
|
||||
export * from './smarthbs.variables';
|
||||
export * from './smarthbs.postprocess';
|
||||
export * from './smarthbs.compile.js';
|
||||
import './smarthbs.helpers.js';
|
||||
export * from './smarthbs.partials.js';
|
||||
export * from './smarthbs.template.js';
|
||||
export * from './smarthbs.variables.js';
|
||||
export * from './smarthbs.postprocess.js';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './smarthbs.plugins';
|
||||
import * as plugins from './smarthbs.plugins.js';
|
||||
|
||||
/**
|
||||
* compiles a directory and outputs it
|
||||
|
@ -1,10 +1,10 @@
|
||||
import * as plugins from './smarthbs.plugins';
|
||||
import * as plugins from './smarthbs.plugins.js';
|
||||
|
||||
/**
|
||||
* Helper:
|
||||
* Allows you to analyze a context
|
||||
*/
|
||||
plugins.handlebars.registerHelper('__analyze', analyzeContext => {
|
||||
plugins.handlebars.registerHelper('__analyze', (analyzeContext) => {
|
||||
if (typeof analyzeContext === 'string') {
|
||||
if (plugins.handlebars.partials[analyzeContext]) {
|
||||
console.log(`The analyzed partial ${analyzeContext} looks like this`);
|
||||
@ -20,7 +20,7 @@ plugins.handlebars.registerHelper('__analyze', analyzeContext => {
|
||||
* Helper:
|
||||
* logs all registered partials to console
|
||||
*/
|
||||
plugins.handlebars.registerHelper('__allPartialsLog', analyzeContext => {
|
||||
plugins.handlebars.registerHelper('__allPartialsLog', (analyzeContext) => {
|
||||
console.log(plugins.handlebars.partials);
|
||||
return 'analyzed';
|
||||
});
|
||||
|
@ -1,11 +1,11 @@
|
||||
import * as plugins from './smarthbs.plugins';
|
||||
import * as plugins from './smarthbs.plugins.js';
|
||||
|
||||
/**
|
||||
* registers a directory of partials to make them available within handlebars compilation
|
||||
*/
|
||||
export let registerPartialDir = (dirPathArg: string): Promise<any> => {
|
||||
let done = plugins.smartpromise.defer();
|
||||
plugins.smartfile.fs.listFileTree(dirPathArg, '**/*.hbs').then(hbsFileArrayArg => {
|
||||
plugins.smartfile.fs.listFileTree(dirPathArg, '**/*.hbs').then((hbsFileArrayArg) => {
|
||||
for (let hbsFilePath of hbsFileArrayArg) {
|
||||
let parsedPath = plugins.path.parse(hbsFilePath);
|
||||
let hbsFileString = plugins.smartfile.fs.toStringSync(
|
||||
|
@ -1,7 +1,15 @@
|
||||
import * as handlebars from 'handlebars';
|
||||
import * as lodash from 'lodash';
|
||||
// node native
|
||||
import * as path from 'path';
|
||||
|
||||
export { path };
|
||||
|
||||
import * as smartpath from '@pushrocks/smartpath';
|
||||
import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
export { handlebars, lodash, path, smartfile, smartpromise };
|
||||
export { smartpath, smartfile, smartpromise };
|
||||
|
||||
// third party
|
||||
import handlebars from 'handlebars';
|
||||
|
||||
export { handlebars };
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './smarthbs.plugins';
|
||||
import * as plugins from './smarthbs.plugins.js';
|
||||
|
||||
let safeSyntaxBeginRegex = /{-{/g;
|
||||
let safeSyntaxEndRegex = /}-}/g;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './smarthbs.plugins';
|
||||
import * as plugins from './smarthbs.plugins.js';
|
||||
|
||||
/**
|
||||
* get a template for a file on disk
|
||||
|
@ -1,7 +1,7 @@
|
||||
// This file contains code that makes it easy to search handlebar templates for variables.
|
||||
// Why? To get a clue if you are missing some.
|
||||
|
||||
import * as plugins from './smarthbs.plugins';
|
||||
import * as plugins from './smarthbs.plugins.js';
|
||||
|
||||
// the curly regex objects
|
||||
let tripleCurlyRegex = /{{{\s*[\w\.]+\s*}}}/g;
|
||||
@ -18,20 +18,23 @@ export let findVarsInHbsString = async (hbsStringArg: string) => {
|
||||
let tripleCurlyMatches = hbsString.match(tripleCurlyRegex);
|
||||
if (tripleCurlyMatches) {
|
||||
hbsString = hbsString.replace(tripleCurlyRegex, '[[[replaced]]]');
|
||||
varNameArray = plugins.lodash.concat(varNameArray, tripleCurlyMatches);
|
||||
varNameArray = varNameArray.concat(tripleCurlyMatches);
|
||||
}
|
||||
let doubleCurlyMatches = hbsString.match(doubleCurlyRegex);
|
||||
if (doubleCurlyMatches) {
|
||||
varNameArray = plugins.lodash.concat(varNameArray, doubleCurlyMatches);
|
||||
varNameArray = varNameArray.concat(doubleCurlyMatches);
|
||||
}
|
||||
|
||||
// make sure we are clean from curly brackets
|
||||
varNameArray = varNameArray.map(x => {
|
||||
varNameArray = varNameArray.map((x) => {
|
||||
return x.match(nameInCurlsRegex)[0];
|
||||
});
|
||||
|
||||
// make sure are uniq
|
||||
varNameArray = plugins.lodash.uniq(varNameArray);
|
||||
function uniqueArray(input: string[]): string[] {
|
||||
return Array.from(new Set(input));
|
||||
}
|
||||
varNameArray = uniqueArray(varNameArray);
|
||||
return varNameArray;
|
||||
};
|
||||
|
||||
|
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
Reference in New Issue
Block a user