Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit 79ba1b4

Browse files
Merge pull request #3 from pattern-lab/dev
Dev
2 parents 230d25c + 0c99d1a commit 79ba1b4

File tree

5 files changed

+70
-9
lines changed

5 files changed

+70
-9
lines changed

.eslintrc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"env": {
33
"node": true,
4-
"builtin": true
4+
"builtin": true,
5+
"es6": true
6+
},
7+
"parserOptions": {
8+
"ecmaVersion": 6,
9+
"sourceType": "module"
510
},
611
"globals": {},
712
"rules": {
@@ -67,7 +72,7 @@
6772
"no-with": 2,
6873
"quotes": [0, "single"],
6974
"radix": 2,
70-
"semi": [0, "never"],
75+
"semi": [1, "always"],
7176
"strict": 0,
7277
"space-before-blocks": 1,
7378
"space-before-function-paren": [1, {
@@ -78,6 +83,10 @@
7883
"space-infix-ops": 1,
7984
"valid-typeof": 2,
8085
"vars-on-top": 0,
81-
"wrap-iife": [2, "inside"]
86+
"wrap-iife": [2, "inside"],
87+
"prefer-const": ["error", {
88+
"destructuring": "any",
89+
"ignoreReadBeforeAssign": false
90+
}]
8291
}
8392
}

_meta/_00-head.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html class="{{ htmlClass }}">
3+
<head>
4+
<title>{{ title }}</title>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width" />
7+
8+
<link rel="stylesheet" href="../../css/style.css?{{ cacheBuster }}" media="all" />
9+
<link rel="stylesheet" href="../../css/pattern-scaffolding.css?{{ cacheBuster }}" media="all" />
10+
11+
<!-- Begin Pattern Lab (Required for Pattern Lab to run properly) -->
12+
{{{ patternLabHead }}}
13+
<!-- End Pattern Lab -->
14+
15+
</head>
16+
<body class="{{ bodyClass }}">

_meta/_01-foot.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
<!--DO NOT REMOVE-->
3+
{{{ patternLabFoot }}}
4+
5+
</body>
6+
</html>

lib/engine_underscore.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use strict";
2+
13
/*
24
* underscore pattern engine for patternlab-node - v0.15.1 - 2015
35
*
@@ -17,8 +19,8 @@
1719
*
1820
*/
1921

20-
21-
"use strict";
22+
const fs = require('fs-extra');
23+
const path = require('path');
2224

2325
var _ = require('underscore');
2426

@@ -85,7 +87,7 @@ _.mixin({
8587
var engine_underscore = {
8688
engine: _,
8789
engineName: 'underscore',
88-
engineFileExtension: '.html',
90+
engineFileExtension: ['.html', '.underscore'],
8991

9092
// partial expansion is only necessary for Mustache templates that have
9193
// style modifiers or pattern parameters (I think)
@@ -171,7 +173,34 @@ var engine_underscore = {
171173
var partialID = partialIDWithQuotes.replace(edgeQuotesMatcher, '');
172174

173175
return partialID;
176+
},
177+
178+
spawnFile: function (config, fileName) {
179+
const paths = config.paths;
180+
const metaFilePath = path.resolve(paths.source.meta, fileName);
181+
try {
182+
fs.statSync(metaFilePath);
183+
} catch (err) {
184+
185+
//not a file, so spawn it from the included file
186+
const localMetaFilePath = path.resolve(__dirname, '_meta/', fileName);
187+
const metaFileContent = fs.readFileSync(path.resolve(__dirname, '..', '_meta/', fileName), 'utf8');
188+
fs.outputFileSync(metaFilePath, metaFileContent);
189+
}
190+
},
191+
192+
/**
193+
* Checks to see if the _meta directory has engine-specific head and foot files,
194+
* spawning them if not found.
195+
*
196+
* @param {object} config - the global config object from core, since we won't
197+
* assume it's already present
198+
*/
199+
spawnMeta: function (config) {
200+
this.spawnFile(config, '_00-head.html');
201+
this.spawnFile(config, '_01-foot.html');
174202
}
203+
175204
};
176205

177206
module.exports = engine_underscore;

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "patternengine-node-underscore",
2+
"name": "@pattern-lab/patternengine-node-underscore",
33
"description": "The Underscore engine for Pattern Lab / Node",
4-
"version": "1.2.0",
4+
"version": "2.0.0-alpha.1",
55
"main": "lib/engine_underscore.js",
66
"dependencies": {
77
"underscore": "^1.8.3"
@@ -24,7 +24,8 @@
2424
"author": "Brian Muenzenmeyer & Geoffrey Pursell",
2525
"license": "MIT",
2626
"scripts": {
27-
"test": "grunt travis --verbose"
27+
"test": "grunt travis --verbose",
28+
"lint": "eslint **/*.js"
2829
},
2930
"engines": {
3031
"node": ">=4.0"

0 commit comments

Comments
 (0)