Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Defining reusable template blocks
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Yang Zhang  
View profile  
 More options Oct 26 2011, 5:46 pm
From: Yang Zhang <yanghates...@gmail.com>
Date: Wed, 26 Oct 2011 14:46:56 -0700
Local: Wed, Oct 26 2011 5:46 pm
Subject: Defining reusable template blocks
I know you can reuse templates by putting the reusable pieces (e.g.
the template for rendering a button) into separate files:

-@ val name: String
-@ val href: String
-@ val body: String
.button-container
  a(href=href) = name
  .button-body != body

and calling:

  render("button.jade", "name" -> "Push Me", "href" -> "go.html",
"body" -> "<img src='foo.png'>")

However I'm wondering if there's something that's (1) lighter weight
and (2) can pass template blocks, along the lines of:

- def button(name: String, href: String)(body: String) =
  .button-container
    a(href=href) = name
    != body

To be used with (e.g.):

!= button("Push Me", "go.html")
  img(src='foo.png')

The lighter-weight definitions would be a boon for small pieces of
abstraction/reusability (like buttons), and passing template bodies
would give these similar power as layouts.

If this doesn't already exist, I think it would make a killer feature.

--
Yang Zhang
http://yz.mit.edu/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hiram Chirino  
View profile  
 More options Oct 26 2011, 10:40 pm
From: Hiram Chirino <hi...@hiramchirino.com>
Date: Wed, 26 Oct 2011 22:40:39 -0400
Local: Wed, Oct 26 2011 10:40 pm
Subject: Re: Defining reusable template blocks
Yes it can be done.   Try:

- def button(name: String, href: String)(body: => Unit) =
 .button-container
   a(href=href) = name
   - body

To be used with (e.g.):

- button("Push Me", "go.html")
 img(src='foo.png')

Regards,
Hiram

FuseSource
Web: http://fusesource.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yang Zhang  
View profile  
 More options Oct 27 2011, 3:21 pm
From: Yang Zhang <yanghates...@gmail.com>
Date: Thu, 27 Oct 2011 12:21:29 -0700
Local: Thurs, Oct 27 2011 3:21 pm
Subject: Re: Defining reusable template blocks
Awesome, thanks Hiram.

--
Yang Zhang
http://yz.mit.edu/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »