snippets of html

13 views
Skip to first unread message

Jon Stevens

unread,
Mar 3, 2012, 1:50:52 AM3/3/12
to cambridge...@googlegroups.com
Let's say I have a block of html that I'd like to repeat many times in my document. Is there a way in cambridge to do that easily?

Ideally, I'd have something like this:

<a:span set="foo">
block of html code here
</a:span>

Then, further down in the document, I could reference that html as many times as I want and it'd get replaced as appropriate...

<a:span var="foo"></a:span>

Obviously, I'm just making up a syntax. Can cambridge do something like that?

thanks,

jon

Erdinc Yilmazel

unread,
Mar 3, 2012, 9:48:19 PM3/3/12
to cambridge...@googlegroups.com
I am thinking about adding a feature to mark snippets of html as macros (Like Velocity macros) but this isn't complete yet. Right now all you can do is including parts of html.

Example:

<!--$include b.html @ /html/body/div -->

The statement above will include the first div inside the body tag of the b.html file. So as you can see in this example, you don't have to include a whole file, but you can include just parts of it.

See http://code.google.com/p/cambridge/wiki/TemplateAuthorsGuide#Includes for an explanation of how this works. (The documentation doesn't mention the @ character separating the file name to the tag selector though. That is something added recently.

I haven't tried this, but you can try including certain parts of the same page to do what you want to do. Another option is creating a template with reusable sets of html snippets and including them in other template files. If you add an id to your tags that you want to reuse and include them like this:

<!--$include snippets.html @ #foo -->

Thanks,

Erdinc
Reply all
Reply to author
Forward
0 new messages