James Sumners avatar James Sumners committed 6c32eef

Switched the order in which things are parsed so that "content" templates can contain tokens.

Comments (0)

Files changed (4)

example/Baker.json

 	},
 
 	"snippets": {
+		"index_aside": "index_aside.html",
 		"index_content": "index_content.html",
 		"about_content": "about_content.html",
 		"site_nav": "site_nav.html"
 	},
 
 	"tokens": [
+		"index_aside",
 		"site_nav"
 	],
 

example/templates/index_aside.html

+<aside>
+	<ol>
+		<li>Item 1</li>
+		<li>Item 2</li>
+		<li>Item 3</li>
+	</ol>
+</aside>

example/templates/index_content.html

 	consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
 	cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
 	proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
-</article>
+</article>
+{{index_aside}}
 	buffer = fs.readFileSync(baker.config.templateDir + '/' + page.template);
 	buffer = buffer.toString();
 
+	// Replace the content token
+	re = new RegExp(tokenDelimA + "content" + tokenDelimB);
+	buffer = buffer.replace(re, snippets[page.content]);
+
 	// Look through the template for tokens and replace them
 	for (var i = 0, j = tokens.length; i < j; i += 1) {
 		re = new RegExp(tokenDelimA + tokens[i] + tokenDelimB);
 		buffer = buffer.replace(re, snippets[tokens[i]], 'g');
 	}
 
-	// Replace the content token
-	re = new RegExp(tokenDelimA + "content" + tokenDelimB);
-	buffer = buffer.replace(re, snippets[page.content]);
-
 	fs.writeFileSync(baker.config.buildDir + '/' + page.file, buffer);
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.