Message from discussion
How to use (plates on the server)?
Received: by 10.50.41.202 with SMTP id h10mr7455429igl.5.1329100109639;
Sun, 12 Feb 2012 18:28:29 -0800 (PST)
X-BeenThere: flatironjs@googlegroups.com
Received: by 10.231.68.202 with SMTP id w10ls11325367ibi.7.gmail; Sun, 12 Feb
2012 18:28:29 -0800 (PST)
Received: by 10.50.203.99 with SMTP id kp3mr7461814igc.0.1329100109179;
Sun, 12 Feb 2012 18:28:29 -0800 (PST)
Received: by 10.50.203.99 with SMTP id kp3mr7461812igc.0.1329100109167;
Sun, 12 Feb 2012 18:28:29 -0800 (PST)
Return-Path: <rob.kob...@gmail.com>
Received: from mail-iy0-f177.google.com (mail-iy0-f177.google.com [209.85.210.177])
by gmr-mx.google.com with ESMTPS id uz1si2424199igc.2.2012.02.12.18.28.29
(version=TLSv1/SSLv3 cipher=OTHER);
Sun, 12 Feb 2012 18:28:29 -0800 (PST)
Received-SPF: pass (google.com: domain of rob.kob...@gmail.com designates 209.85.210.177 as permitted sender) client-ip=209.85.210.177;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of rob.kob...@gmail.com designates 209.85.210.177 as permitted sender) smtp.mail=rob.kob...@gmail.com; dkim=pass header...@gmail.com
Received: by iafj26 with SMTP id j26so9187164iaf.8
for <flatironjs@googlegroups.com>; Sun, 12 Feb 2012 18:28:29 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=gamma;
h=mime-version:sender:in-reply-to:references:date
:x-google-sender-auth:message-id:subject:from:to:content-type;
bh=XIVLP2Pm80eBA9/D9uIS6QO6RDFB/mPPnzT2peI3ATg=;
b=bBzf8v+MFWvlwTVnwYLj8QL+zejTS0QwndsRWgoMPkJjxd0ygzQLGv/XUlYv9d70j2
P5OMw5cHnIhy7vQ9BW5LP34VVN+DcenfomvNGI0F8rRzE9UQnkkDXpC+pdem9Bma3XhF
sruyM+nkvdCy3I9qLJP/gQvJ2shvZPa1qzUyU=
MIME-Version: 1.0
Received: by 10.42.135.138 with SMTP id p10mr19070696ict.25.1329100108927;
Sun, 12 Feb 2012 18:28:28 -0800 (PST)
Sender: rob.kob...@gmail.com
Received: by 10.231.202.209 with HTTP; Sun, 12 Feb 2012 18:28:28 -0800 (PST)
In-Reply-To: <23798426.731.1329079885754.JavaMail.geo-discussion-forums@ynca2>
References: <616c4935-ef6c-4b2a-9ec3-04b440b86...@9g2000pbd.googlegroups.com>
<CAHL2YmrqW8b7VfTx4XQ8fkGZTYZcrHa-Q08mnTB5RWMRpu3...@mail.gmail.com>
<CAEku0uviPXTWUccdEE20LKJMnh9o6Nk_4Kb-nYnL8RypUJa...@mail.gmail.com>
<CAEku0uuHpbVx-3PijErh1XsCABjVQwMq11omUbJD4bLHG6n...@mail.gmail.com>
<23798426.731.1329079885754.JavaMail.geo-discussion-forums@ynca2>
Date: Sun, 12 Feb 2012 18:28:28 -0800
Message-ID: <CAEku0ut7JO4po=8KgwLZNaQCWm+JSqxB2GfVas0qYDHuizT...@mail.gmail.com>
Subject: Re: [flatironjs] How to use (plates on the server)?
From: Rob Koberg <r...@koberg.com>
To: flatironjs@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1
On Sun, Feb 12, 2012 at 12:51 PM, bradley.meck <bradley.m...@gmail.com> wrote:
> I agree that there may be some need to create a step by step example
> project. What exactly are you looking for in an example that is difficult to
> find right now?
From my previous post:
"From what I can determine so far for plates, I would need to load
template files from the file system into strings (or heaven forbid,
write the HTML into the code) to assemble into an HTML page (creating
my own caching scheme), send that string to the response stream while
writing all the headers I need for each response. Is that the case?"
Say I have a page wrapper template and a list of blog entries for one case:
file system path/to/templates/wrapper.html:
<html>
<head>
<title>Change to current page title | This site's static name</title>
</head>
<body>
<header>
<h1>Current page title</h1>
</header>
<div id="page-content">
<p>Current page content replaces this</p>
</div>
<footer>
<p>© <span class="site-name">Site's static name</span>
<span class="current-year">Current year</span></p>
</footer>
</body>
</html>
And a request is made for /blog (list of blog entries), where the
(wrapper sub) template for the 'Current page content' is:
file system path/to/templates/blog.html:
<ol id="blog-entries">
<li class="blog-entry" role="template">
<h2>Example entry 1</h2>
<div class="authoring">
<img src="http://placehold.it/30x30"/>
<span class="author">Some author</span>
<span class="last-edited">Some date format</span>
</div>
<div class="blog-entry-content">
<p>Lorem ipsum...</p>
</div>
<div class="links">
<a class="read-more" href="some/path">Read more</a>
</div>
</li>
<li class="blog-entry">
<h2>Example entry 2</h2>
<div class="blog-entry-content">
<p>Lorem ipsum...</p>
</div>
</li>
</ol>
How does the response get assembled? *not how to fill in the content
of the templates* I understand how to replace the placeholder content
based on the page structure, IDs, and classes. I would use Plates's
way to get to the #blog-entries>li[role='template'] to use as an blog
entry template and fill in the replaceable parts with plates way of
selecting page elements and attributes, repeating for each blog entry
on the page and return that wrapped in the <ol id="blog-entries"/> to
the wrapper template's div#page-content. (I would actually break the
above blog-entries out into several sub-sub-templates.)
If I am understanding correctly, I need to load those two files from
the file system in my custom code based on some convention of my own
making. Those files need to be read into strings. I would need to
cache the strings for the two templates, checking for file changes in
a dev environment and provide a way to clear that cache in a
production environment in my custom code. Then I would need to
determine the appropriate headers to send along with the assembled
string (probably setting up a caching system for that fully
assembled/transformed/rendered page).
Did that make sense? Am I missing any conveniences flatiron provides
along the way so I don't have to come up with all the custom code?
Thanks,
-Rob