Home Download Buy Blog Forum Support

Sublime Text 2 as '@includes' substitution

Sublime Text 2 as '@includes' substitution

Postby stormtitan on Tue Nov 06, 2012 4:07 pm

So in my current situation, I'm building out a library of information on my company's product. It's an internal library. The boss has told me that I have to code it locally as HTML/CSS and post it to Git. Others wanting to use it will then pull the repository and open it locally.

So--no PHP@includes, no Server Side Includes.

Is there a way to '@import' or '@include' files, just like I would do with PHP? e.g. I build out a 'navigation.html' file, and maintain my navigation in that one file. In all of my other files, I'd just do <import file command here>navigation.html, and get my menu generated in that fashion?

Thanks!
stormtitan
 
Posts: 4
Joined: Tue Nov 06, 2012 4:04 pm

Re: Sublime Text 2 as '@includes' substitution

Postby agibsonsw on Tue Nov 06, 2012 6:41 pm

Client-side includes is the terminology, but it's not as straight-forward as just including a file. (The link discusses the process, and advises of some pitfalls.)

Essentially, you can attach a javascript file, which includes a function, which uses document.write to write to the file at the current location.
Easier would be to use an iframe to include content at a specific point in your document.
A third alternative occurs to me - which is to wait until the document has loaded and use JavaScript to manipulate, and append to, the DOM-body - but there is probably no advantage to this approach compared to the first mentioned method.

If you decide to pursue a copy/paste approach you could consider adding specific comments at certain points in the files and use ST's Find/Replace in Files feature (or some other file utility) to replace (or append after) the comments in one fell swoop. I think you would need to plan this carefully, and I would consider something like this:

<!-- include:navigation.html -->
<!-- include:end -->

so that you could insert the text between these comments and repeat the process at a later-stage if you needed to. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Sublime Text 2 as '@includes' substitution

Postby stormtitan on Tue Nov 06, 2012 7:26 pm

The javascript client side includes was a good solution, thank you!
stormtitan
 
Posts: 4
Joined: Tue Nov 06, 2012 4:04 pm


Return to General Discussion

Who is online

Users browsing this forum: hoest and 20 guests