Skip to content

Commit

Permalink
pages can be built from templates if needed. closes #5
Browse files Browse the repository at this point in the history
had to remove an arbitrary limit. now supports the tactic @dmolsen outlined here: pattern-lab/patternlab-php#31
  • Loading branch information
bmuenzenmeyer committed Feb 7, 2015
1 parent 5fb37c2 commit abf83e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 105 deletions.
23 changes: 6 additions & 17 deletions builder/patternlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ var patternlab_engine = function(){
var cleanSub = sub.substring(0, folderIndex);

//add any templates found to an object of partials, so downstream templates may use them too
//exclude the template patterns - we don't need them as partials because pages will just swap data
//look for the full path on nested patters, else expect it to be flat
var partialname = '';
if(cleanSub !== ''){
var partialname = cleanSub + '-' + patternName.substring(patternName.indexOf('-') + 1);

patternlab.partials[partialname] = currentPattern.template;

//done
partialname = cleanSub + '-' + patternName.substring(patternName.indexOf('-') + 1);
} else{
partialname = currentPattern.patternGroup + '-' + patternName.substring(patternName.indexOf('-') + 1);
}
patternlab.partials[partialname] = currentPattern.template;

//add to patternlab arrays so we can look these up later. this could probably just be an object.
patternlab.patternIndex.push(currentPattern.name);
Expand All @@ -160,9 +160,6 @@ var patternlab_engine = function(){

//write the encoded version too
fs.outputFileSync('./public/patterns/' + pattern.patternLink.replace('.html', '.escaped.html'), entity_encoder.encode(pattern.patternPartial));



});

//export patterns if necessary
Expand Down Expand Up @@ -335,19 +332,11 @@ var patternlab_engine = function(){
var viewAllPathsTemplate = fs.readFileSync('./source/_patternlab-files/partials/viewAllPaths.mustache', 'utf8');
var viewAllPathersPartialHtml = renderPattern(viewAllPathsTemplate, {'viewallpaths': JSON.stringify(patternlab.viewAllPaths)});

//websockets
var websocketsTemplate = fs.readFileSync('./source/_patternlab-files/partials/websockets.mustache', 'utf8');
patternlab.contentsyncport = patternlab.config.contentSyncPort;
patternlab.navsyncport = patternlab.config.navSyncPort;

var websocketsPartialHtml = renderPattern(websocketsTemplate, patternlab);

//render the patternlab template, with all partials
var patternlabSiteHtml = renderPattern(patternlabSiteTemplate, {}, {
'ishControls': ishControlsPartialHtml,
'patternNav': patternNavPartialHtml,
'patternPaths': patternPathsPartialHtml,
'websockets': websocketsPartialHtml,
'viewAllPaths': viewAllPathersPartialHtml
});
fs.outputFileSync('./public/index.html', patternlabSiteHtml);
Expand Down
38 changes: 1 addition & 37 deletions source/_patterns/04-pages/00-homepage.mustache
Original file line number Diff line number Diff line change
@@ -1,37 +1 @@
<div class="page" id="page">
{{> organisms-header }}
<div role="main">

{{# hero }}
{{> molecules-block-hero }}
{{/ hero}}

<div class="g g-3up">
{{# touts}}
<div class="gi">
{{> molecules-inset-block }}
</div>
{{/ touts}}
</div><!--end 3up-->

<hr />

<div class="l-two-col">
<div class="l-main">
<section class="section latest-posts">
<h2 class="section-title">Latest Posts</h2>
<ul class="post-list">
{{# latest-posts}}
<li>{{> molecules-media-block }}</li>
{{/ latest-posts}}
</ul>
<a href="#" class="text-btn">View more posts</a>
</section>
</div>

<div class="l-sidebar">
{{> organisms-recent-tweets }}
</div><!--end l-sidebar-->
</div><!--End role=main-->
{{> organisms-footer }}
</div>
{{> templates-homepage }}
52 changes: 1 addition & 51 deletions source/_patterns/04-pages/02-article.mustache
Original file line number Diff line number Diff line change
@@ -1,51 +1 @@
<div class="page" id="page">
{{> organisms-header }}
<div role="main">
<div class="l-two-col">
<div class="l-main">
<article class="article">
<header class="article-header">
<h1>Top 10 Trails You Have To Hike Before You Die</h1>
{{> molecules-byline-author-time }}
</header>
<p class="intro">This is where a post about hiking trails would live. I'm not going to write an article about hiking trails. That would take a lot of time.</p>

<p><a href="#">This is a link, possibly to an external resource.</a> In a post about hiking trails, there would probably be talk about how to get to featured trails, what to pack, where to camp, and so on and so forth. I don't have any expertise in this subject matter so I'm not going to attempt to write about it.</p>

{{> atoms-landscape-16x9 }}

<p>If I were to write about it, I'd probably do some research on the topic first. But even then, I probably Sed a orci turpis. Aliquam aliquet placerat dui, consectetur tincidunt leo tristique et. Vivamus enim nisi, blandit a venenatis quis, convallis et arcu. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris libero sapien, placerat in sodales eu, tempor quis dui. Vivamus egestas faucibus pulvinar. Maecenas eget diam nunc. Phasellus at sem eros, ac suscipit neque. Phasellus sollicitudin libero a odio dignissim scelerisque. Aliquam purus nulla, tempor eget ullamcorper quis, rhoncus non dui.
</p>

<blockquote>
This trail is amazing. I've never seen anything like it.
</blockquote>

<p>Cras at fringilla ipsum. Donec nec libero eget est blandit dignissim a eu ante. Morbi augue nulla, luctus eu sagittis vel, malesuada ut felis. Aliquam erat volutpat. Morbi malesuada augue ac massa hendrerit fermentum. Integer scelerisque lacus a dolor convallis lobortis. Curabitur mollis ante in massa ultricies dignissim.
</p>

{{> atoms-unordered }}

{{> atoms-ordered }}

<p>Donec posuere fringilla nunc, vitae venenatis diam scelerisque vel. Nullam vitae mauris magna. Mauris et diam quis justo volutpat tincidunt congue nec magna. Curabitur vitae orci elit. Ut mollis massa id magna vestibulum consequat. Proin rutrum lectus justo, sit amet tincidunt est. Vivamus vitae lacinia risus.
</p>

{{> molecules-pullquote }}

<p>Donec venenatis imperdiet tortor, vitae blandit odio interdum ut. Integer orci metus, lobortis id lacinia eget, rutrum vitae justo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In pretium fermentum justo nec pharetra. Maecenas eget dapibus justo. Ut quis est risus. Nullam et eros at odio commodo venenatis quis et augue. Sed sed augue at tortor porttitor hendrerit nec ut nibh. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin sollicitudin enim consectetur mi commodo quis cursus ante pretium. Nunc gravida cursus nisi in gravida. Suspendisse eget tortor sed urna consequat tincidunt. Etiam eget convallis lectus. Suspendisse cursus rutrum massa ac faucibus.
</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reiciendis, suscipit repellendus nulla accusantium deserunt sed explicabo voluptate sapiente ratione inventore molestiae nihil earum repellat quia odit vitae perspiciatis aliquam amet?</p>
</article><!--end .article-->
{{> molecules-social-share }}
{{> organisms-comment-thread }}
</div><!--end l-main-->

<div class="l-sidebar">
{{> organisms-related-posts }}
{{> organisms-recent-tweets }}
</div><!--end l-sidebar-->
</div><!--end l-two-col-->
</div><!--End role=main-->
{{> organisms-footer }}
</div>
{{> templates-article }}

0 comments on commit abf83e6

Please sign in to comment.