Sublime Forum

How to do Dreamweaver-style HTML templates?

#1

So I recently switched over to Sublime Text 2, loving it so far. One thing I loved about Dreamweaver was its templates feature. I make a lot of large websites for clients and DW’s built-in template system (.dwt files) was fantastic for it. I know Sublime Text 2 has snippets, but do they offer all the dynamic functionalities that the .DWT files do?

I like the snippets feature and the tab trigger options for instantly importing code, but what if I want to control specific elements? For example, say I made a giant navigation bar with sub-navigations for each one and made a snippet out of it. Then I import it into other pages on my site via the tab trigger. Now what if the client wants one of the names for the sub-navigation changed to something else? I’m going to have to change it on every single page, right? Or will just changing it in the snippet file update all the pages?

I’m very used to Dreamweaver’s template system and I’m wondering if Sublime Text 2’s snippets feature is powerful enough to handle that kind of dynamic functionality and whether or not it’s capable of updating one template element across all the pages (that the template is applied to) on the fly.

Any advice/tips/suggestions appreciated.

0 Likes

#2

Sublime snippets are not dynamic in that way. Once inserted in a document, they expand to plain text. I don’t know if something similar to DW templates exist.

But if you like how DreamWeaver does it, and already are using such functionality, why do you want to switch?

0 Likes

#3

What I do is to use server side includes [en.wikipedia.org/wiki/Server_Side_Includes] to handle the sections of code, such as menus or footers, that are common across a site, so, for example, in your page you add the menu using something like this:

<?php require_once('includes/navigation.inc.php'); ?>

My navigation.inc.php file (I use the .inc in the file name just to signify that it is an ‘include’) would contain this:

	<div id="nav">
		<ul>
			<li><a href="/index.php" title="Home">Home</a></li>
			<li><a href="/about.php" title="About Us">About Us</a></li>
			<li><a href="/services.php" title="Services">Services</a></li>
			<li><a href="/contact.php" title="Contact">Contact</a></li>
		</ul>
	</div>

HTH

Cheers,
Mick

0 Likes

#4

You could perhaps hack something vaguely similar together with snippets and macros but in the general case, templating to that extent is way outside the domain of a text editor.

Anyway, the last poster was bang on. I’d go even further and say that any other method of doing it is actually wrong (substandard at the very least). Don’t rely on your editing software to maintain consistent static pages for you. It’s cumbersome and, beyond a certain point, practically untenable.

0 Likes