diff --git a/Gruntfile.js b/Gruntfile.js
index 59c910bf..95c66335 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -33,7 +33,7 @@ module.exports = function(grunt) {
componentName,
componentNameCamelCase,
componentNameUpperCase,
- liveEditJS;
+ liveEditJS = '';
// File has no code sample
if (matchedJS === null) {
@@ -41,29 +41,31 @@ module.exports = function(grunt) {
};
// Here we should iterate over matched code samples
- matchedJS = matchedJS[0];
- // Remove markdown syntax
- matchedJS = matchedJS.slice(5, -3);
+ for( var i = 0; i < matchedJS.length; i++) {
- // remove file extension
- componentName = filename.slice(0, -3);
+ // Remove markdown syntax
+ matchedJS = matchedJS[i].slice(5, -3);
- componentNameCamelCase = componentName;
+ // remove file extension
+ componentName = filename.slice(0, -3) + i;
+
+ // Uppercase with underscores (FOO_COMPONENT)
+ componentNameUpperCase = componentName.toUpperCase().replace(/[\. ,:-]+/g, "_").slice(6);
- componentNameUpperCase = componentName.toUpperCase().replace(/[\. ,:-]+/g, "_").slice(6);
+ // Camelcase (fooExample)
+ componentNameCamelCase = componentName.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase() }).slice(5);
+ // Add code sample to live edit
+ liveEditJS += '/**\n * @jsx React.DOM\n */\n\n var ' + componentNameUpperCase + '_COMPONENT = "' + matchedJS + '";\n React.renderComponent(\n ReactPlayground( {codeText:' + componentNameUpperCase + '_COMPONENT} ),\n document.getElementById("' + componentNameCamelCase + '")\n );'
+
+ writeToLiveSampleJS(liveEditJS, componentName);
-
- componentNameCamelCase = componentNameCamelCase.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase() }).slice(5);
-
- // Add code sample to live edit
- liveEditJS = '/**\n * @jsx React.DOM\n */\n\n var ' + componentNameUpperCase + '_COMPONENT = "' + matchedJS + '";\n React.renderComponent(\n ReactPlayground( {codeText:' + componentNameUpperCase + '_COMPONENT} ),\n document.getElementById("' + componentNameCamelCase + '")\n );'
- console.log(componentName);
+ }
- writeToLiveSampleJS(liveEditJS, componentName);
+
// writeToHTML(markdown, componentName);
}
diff --git a/js/cookbook/cb-02-inline-styles tip.js b/js/cookbook/cb-02-inline-styles tip.js
deleted file mode 100644
index 11150581..00000000
--- a/js/cookbook/cb-02-inline-styles tip.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * @jsx React.DOM
- */
-
- var INLINE_STYLES_TIP_COMPONENT = "
-/** @jsx React.DOM */
-
-var divStyle = {
- color: 'white',
- backgroundImage: 'url(' + imgUrl + ')',
- WebkitTransition: 'all' // note the capital 'W' here
-};
-
-React.renderComponent(
Hello World!
, mountNode);
-";
- React.renderComponent(
- ReactPlayground( {codeText:INLINE_STYLES_TIP_COMPONENT} ),
- document.getElementById("InlineStyles tip")
- );
\ No newline at end of file
diff --git a/js/cookbook/cb-02-inline-styles.js b/js/cookbook/cb-02-inline-styles.js
deleted file mode 100644
index b01b79ed..00000000
--- a/js/cookbook/cb-02-inline-styles.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * @jsx React.DOM
- */
-
- var INLINE_STYLES_COMPONENT = "
-/** @jsx React.DOM */
-
-var divStyle = {
- color: 'white',
- backgroundImage: 'url(' + imgUrl + ')',
- WebkitTransition: 'all' // note the capital 'W' here
-};
-
-React.renderComponent(Hello World!
, mountNode);
-";
- React.renderComponent(
- ReactPlayground( {codeText:INLINE_STYLES_COMPONENT} ),
- document.getElementById("InlineStyles")
- );
\ No newline at end of file
diff --git a/js/cookbook/cb-03-if-else-in-JSX tip.js b/js/cookbook/cb-03-if-else-in-JSX tip.js
deleted file mode 100644
index 2542f833..00000000
--- a/js/cookbook/cb-03-if-else-in-JSX tip.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * @jsx React.DOM
- */
-
- var IF_ELSE_IN_JSX_TIP_COMPONENT = "
-/** @jsx React.DOM */
-
-// this
-React.renderComponent(Hello World!
, mountNode);
-// is the same as this
-React.renderComponent(React.DOM.div({id:"msg"}, "Hello World!"), mountNode);
-";
- React.renderComponent(
- ReactPlayground( {codeText:IF_ELSE_IN_JSX_TIP_COMPONENT} ),
- document.getElementById("IfElseIn-JSX tip")
- );
\ No newline at end of file
diff --git a/js/cookbook/cb-03-if-else-in-JSX.js b/js/cookbook/cb-03-if-else-in-JSX.js
deleted file mode 100644
index c5ad0e52..00000000
--- a/js/cookbook/cb-03-if-else-in-JSX.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * @jsx React.DOM
- */
-
- var IF_ELSE_IN_JSX_COMPONENT = "
-/** @jsx React.DOM */
-
-// this
-React.renderComponent(Hello World!
, mountNode);
-// is the same as this
-React.renderComponent(React.DOM.div({id:"msg"}, "Hello World!"), mountNode);
-";
- React.renderComponent(
- ReactPlayground( {codeText:IF_ELSE_IN_JSX_COMPONENT} ),
- document.getElementById("IfElseIn-JSX")
- );
\ No newline at end of file
diff --git a/js/cookbook/cb-06-style-prop-value-px tip.js b/js/cookbook/cb-06-style-prop-value-px tip.js
deleted file mode 100644
index 38e951ab..00000000
--- a/js/cookbook/cb-06-style-prop-value-px tip.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * @jsx React.DOM
- */
-
- var STYLE_PROP_VALUE_PX_TIP_COMPONENT = "
-/** @jsx React.DOM */
-
-var divStyle = {height: 10}; // rendered as "height:10px"
-React.renderComponent(Hello World!
, mountNode);
-";
- React.renderComponent(
- ReactPlayground( {codeText:STYLE_PROP_VALUE_PX_TIP_COMPONENT} ),
- document.getElementById("StylePropValuePx tip")
- );
\ No newline at end of file
diff --git a/js/cookbook/cb-06-style-prop-value-px.js b/js/cookbook/cb-06-style-prop-value-px.js
deleted file mode 100644
index 90b91d66..00000000
--- a/js/cookbook/cb-06-style-prop-value-px.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * @jsx React.DOM
- */
-
- var STYLE_PROP_VALUE_PX_COMPONENT = "
-/** @jsx React.DOM */
-
-var divStyle = {height: 10}; // rendered as "height:10px"
-React.renderComponent(Hello World!
, mountNode);
-";
- React.renderComponent(
- ReactPlayground( {codeText:STYLE_PROP_VALUE_PX_COMPONENT} ),
- document.getElementById("StylePropValuePx")
- );
\ No newline at end of file
diff --git a/js/cookbook/cb-08-controlled-input-null-value tip.js b/js/cookbook/cb-08-controlled-input-null-value tip.js
deleted file mode 100644
index 41a42fb6..00000000
--- a/js/cookbook/cb-08-controlled-input-null-value tip.js
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * @jsx React.DOM
- */
-
- var CONTROLLED_INPUT_NULL_VALUE_TIP_COMPONENT = "
-/** @jsx React.DOM */
-
-React.renderComponent(, mountNode);
-
-setTimeout(function() {
- React.renderComponent(, mountNode);
-}, 2000);
-";
- React.renderComponent(
- ReactPlayground( {codeText:CONTROLLED_INPUT_NULL_VALUE_TIP_COMPONENT} ),
- document.getElementById("ControlledInputNullValue tip")
- );
\ No newline at end of file
diff --git a/js/cookbook/cb-08-controlled-input-null-value.js b/js/cookbook/cb-08-controlled-input-null-value.js
deleted file mode 100644
index cfd03189..00000000
--- a/js/cookbook/cb-08-controlled-input-null-value.js
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * @jsx React.DOM
- */
-
- var CONTROLLED_INPUT_NULL_VALUE_COMPONENT = "
-/** @jsx React.DOM */
-
-React.renderComponent(, mountNode);
-
-setTimeout(function() {
- React.renderComponent(, mountNode);
-}, 2000);
-";
- React.renderComponent(
- ReactPlayground( {codeText:CONTROLLED_INPUT_NULL_VALUE_COMPONENT} ),
- document.getElementById("ControlledInputNullValue")
- );
\ No newline at end of file