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

Commit bcc2650

Browse files
committed
cheapest, most useless hello world
1 parent 913119a commit bcc2650

File tree

1 file changed

+23
-43
lines changed

1 file changed

+23
-43
lines changed

lib/engine_react.js

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* mustache pattern engine for patternlab-node - v2.X.X - 2016
2+
* react pattern engine for patternlab-node - v0.1.0 - 2016
33
*
44
* Geoffrey Pursell, Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -13,41 +13,37 @@
1313
*
1414
* Full + extensions. Partial calls and lineage hunting are supported. Style
1515
* modifiers and pattern parameters are used to extend the core feature set of
16-
* Mustache templates.
16+
* React templates.
1717
*
1818
*/
1919

2020
"use strict";
2121

22-
var Mustache = require('mustache');
23-
var utilMustache = require('./util_mustache');
22+
var React = {};
2423

25-
var engine_mustache = {
26-
engine: Mustache,
27-
engineName: 'mustache',
28-
engineFileExtension: '.mustache',
24+
var engine_react = {
25+
engine: React,
26+
engineName: 'react',
27+
engineFileExtension: '.jsx',
2928

30-
// partial expansion is only necessary for Mustache templates that have
29+
// partial expansion is only necessary for React templates that have
3130
// style modifiers or pattern parameters (I think)
32-
expandPartials: true,
31+
expandPartials: false,
3332

3433
// regexes, stored here so they're only compiled once
35-
findPartialsRE: utilMustache.partialsRE,
36-
findPartialsWithStyleModifiersRE: utilMustache.partialsWithStyleModifiersRE,
37-
findPartialsWithPatternParametersRE: utilMustache.partialsWithPatternParametersRE,
38-
findListItemsRE: utilMustache.listItemsRE,
39-
findPartialRE: utilMustache.partialRE,
34+
findPartialsRE: null,
35+
findPartialsWithStyleModifiersRE: null,
36+
findPartialsWithPatternParametersRE: null,
37+
findListItemsRE: null,
38+
findPartialRE: null,
4039

4140
// render it
4241
renderPattern: function renderPattern(pattern, data, partials) {
4342
try {
44-
if (partials) {
45-
return Mustache.render(pattern.extendedTemplate, data, partials);
46-
}
47-
return Mustache.render(pattern.extendedTemplate, data);
43+
return "hey! this should be react, yeah";
4844
} catch (e) {
49-
debugger;
50-
console.log("e = ", e);
45+
console.log("e = ", e);
46+
return "";
5147
}
5248
},
5349

@@ -70,48 +66,32 @@ var engine_mustache = {
7066

7167
// find and return any {{> template-name }} within pattern
7268
findPartials: function findPartials(pattern) {
73-
var matches = this.patternMatcher(pattern, this.findPartialsRE);
74-
return matches;
69+
return [];
7570
},
7671
findPartialsWithStyleModifiers: function (pattern) {
77-
var matches = this.patternMatcher(pattern, this.findPartialsWithStyleModifiersRE);
78-
return matches;
72+
return [];
7973
},
8074

8175
// returns any patterns that match {{> value(foo:"bar") }} or {{>
8276
// value:mod(foo:"bar") }} within the pattern
8377
findPartialsWithPatternParameters: function (pattern) {
84-
var matches = this.patternMatcher(pattern, this.findPartialsWithPatternParametersRE);
85-
return matches;
78+
return [];
8679
},
8780
findListItems: function (pattern) {
88-
var matches = this.patternMatcher(pattern, this.findListItemsRE);
89-
return matches;
81+
return [];
9082
},
9183

9284
// given a pattern, and a partial string, tease out the "pattern key" and
9385
// return it.
9486
findPartial_new: function (partialString) {
95-
var partial = partialString.replace(this.findPartialRE, '$1');
96-
return partial;
87+
return [];
9788
},
9889

9990
// GTP: the old implementation works better. We might not need
10091
// this.findPartialRE anymore if it works in all cases!
10192
findPartial: function (partialString) {
102-
//strip out the template cruft
103-
var foundPatternPartial = partialString.replace("{{> ", "").replace(" }}", "").replace("{{>", "").replace("}}", "");
104-
105-
// remove any potential pattern parameters. this and the above are rather brutish but I didn't want to do a regex at the time
106-
if (foundPatternPartial.indexOf('(') > 0) {
107-
foundPatternPartial = foundPatternPartial.substring(0, foundPatternPartial.indexOf('('));
108-
}
109-
110-
//remove any potential stylemodifiers.
111-
foundPatternPartial = foundPatternPartial.split(':')[0];
11293

113-
return foundPatternPartial;
11494
}
11595
};
11696

117-
module.exports = engine_mustache;
97+
module.exports = engine_react;

0 commit comments

Comments
 (0)