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

Commit

Permalink
Merge pull request #3 from pattern-lab/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
bmuenzenmeyer authored Oct 21, 2017
2 parents 230d25c + 0c99d1a commit 79ba1b4
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 9 deletions.
15 changes: 12 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"env": {
"node": true,
"builtin": true
"builtin": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"globals": {},
"rules": {
Expand Down Expand Up @@ -67,7 +72,7 @@
"no-with": 2,
"quotes": [0, "single"],
"radix": 2,
"semi": [0, "never"],
"semi": [1, "always"],
"strict": 0,
"space-before-blocks": 1,
"space-before-function-paren": [1, {
Expand All @@ -78,6 +83,10 @@
"space-infix-ops": 1,
"valid-typeof": 2,
"vars-on-top": 0,
"wrap-iife": [2, "inside"]
"wrap-iife": [2, "inside"],
"prefer-const": ["error", {
"destructuring": "any",
"ignoreReadBeforeAssign": false
}]
}
}
16 changes: 16 additions & 0 deletions _meta/_00-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html class="{{ htmlClass }}">
<head>
<title>{{ title }}</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width" />

<link rel="stylesheet" href="../../css/style.css?{{ cacheBuster }}" media="all" />
<link rel="stylesheet" href="../../css/pattern-scaffolding.css?{{ cacheBuster }}" media="all" />

<!-- Begin Pattern Lab (Required for Pattern Lab to run properly) -->
{{{ patternLabHead }}}
<!-- End Pattern Lab -->

</head>
<body class="{{ bodyClass }}">
6 changes: 6 additions & 0 deletions _meta/_01-foot.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

<!--DO NOT REMOVE-->
{{{ patternLabFoot }}}

</body>
</html>
35 changes: 32 additions & 3 deletions lib/engine_underscore.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

/*
* underscore pattern engine for patternlab-node - v0.15.1 - 2015
*
Expand All @@ -17,8 +19,8 @@
*
*/


"use strict";
const fs = require('fs-extra');
const path = require('path');

var _ = require('underscore');

Expand Down Expand Up @@ -85,7 +87,7 @@ _.mixin({
var engine_underscore = {
engine: _,
engineName: 'underscore',
engineFileExtension: '.html',
engineFileExtension: ['.html', '.underscore'],

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

return partialID;
},

spawnFile: function (config, fileName) {
const paths = config.paths;
const metaFilePath = path.resolve(paths.source.meta, fileName);
try {
fs.statSync(metaFilePath);
} catch (err) {

//not a file, so spawn it from the included file
const localMetaFilePath = path.resolve(__dirname, '_meta/', fileName);
const metaFileContent = fs.readFileSync(path.resolve(__dirname, '..', '_meta/', fileName), 'utf8');
fs.outputFileSync(metaFilePath, metaFileContent);
}
},

/**
* Checks to see if the _meta directory has engine-specific head and foot files,
* spawning them if not found.
*
* @param {object} config - the global config object from core, since we won't
* assume it's already present
*/
spawnMeta: function (config) {
this.spawnFile(config, '_00-head.html');
this.spawnFile(config, '_01-foot.html');
}

};

module.exports = engine_underscore;
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "patternengine-node-underscore",
"name": "@pattern-lab/patternengine-node-underscore",
"description": "The Underscore engine for Pattern Lab / Node",
"version": "1.2.0",
"version": "2.0.0-alpha.1",
"main": "lib/engine_underscore.js",
"dependencies": {
"underscore": "^1.8.3"
Expand All @@ -24,7 +24,8 @@
"author": "Brian Muenzenmeyer & Geoffrey Pursell",
"license": "MIT",
"scripts": {
"test": "grunt travis --verbose"
"test": "grunt travis --verbose",
"lint": "eslint **/*.js"
},
"engines": {
"node": ">=4.0"
Expand Down

0 comments on commit 79ba1b4

Please sign in to comment.