Giter Site home page Giter Site logo

Comments (2)

bradfrost avatar bradfrost commented on May 30, 2024

I agree, and meant to bring that up earlier.

The way it should work is that pages should be able to take just a .json
file. That will work for a few use cases and keep thing DRY.

But there are a lot of instances where the page's markup will differ from
the main template. It would be cool to control all variations (for example,
a homepage page instance where there's an emergency, or during a live
event, or some other special edition) with JSON, but I can see how that
could end up being cumbersome. So I still think it would be valuable to be
able to create .mustache files for pages.

On Sunday, October 27, 2013, Dave Olsen wrote:

Should Pages have mustache-based mark-up? It seems like they really should
just be Templates (the base mark-up) with custom data (to make the
Pages more "real"
). If that's the case then the only files that should
be in 04-pages/ should be the .json files. This would make PL a little
DRYer and make it easier to update Templates and Pages at the same time.

For example, the changes made when updating 03-templates/homepage.mustacheshould be seen when viewing templates

homepage or pages > homepage on the PL site.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28
.


Brad Frost
http://bradfrostweb.com
http://twitter.com/brad_frost

Sent from a tiny computer that fits in my pocket and also happens to make
phone calls.

from patternlab-php.

dmolsen avatar dmolsen commented on May 30, 2024

Ok, so we want a one-to-many relationship between Templates and Pages. And we might be able to "turn on" sections of a template with the JSON. For example, you could have a Template named homepage.mustache with this code:

<h1>Hello World</h1>
{{# emergency }}
   <div>Emergency!!!!!</div>
{{/ emergency }}
<div id="normal-news">
   [ normal stuff ]
</div>

And then have a default Page JSON for that template named homepage.json which was a vanilla data replacement looking like:

{
    "normal-news-items": [ stuff ]
}

With this data the emergency section of the homepage Template doesn't show when rendered because there's no emergency variable. To get the emergency version of the template we'd have a second Page JSON file, named homepage-emergency.json, which showed had the emergency variable:

{
    "emergency": true;
}

That's a way of giving Mustache the ability to handle a simple if statement. PL could use homepage.json as the base and then render Pages based on one or more related JSON files. By having homepage.json and homepage-emergency.json files we'd end up with two rendered Pages based on one Template.

I can keep the Pages support we have now too.

from patternlab-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.