Hi,
After a quick search of the TextMate Wiki and archives of this list, I am writing to ask about TextMate's ability to support a useful feature related to BBEdit's support for creating websites.
In particular, BBEdit has a feature called "bbinclude" that allows one to insert statements like
<!-- #bbinclude "footer.html" --> <!-- end bbinclude -->
into an HTML file. You can then "update" the host file and BBEdit pulls in the text from the referenced file and includes it in the host file.
For instance, my footer.html file looks like this:
<div id="footer"> <p>© Kenneth M. Anderson, 1998-#YEARNUM#.</p> <p>Last Updated: #SHORTDATE#; #TIME#</p> </div>
and when I run the update command, it generates text like this:
<!-- #bbinclude "footer.html" --> <div id="footer"> <p>© Kenneth M. Anderson, 1998-2006.</p> <p>Last Updated: 08/01/06; 3:43 PM</p> </div> <!-- end bbinclude -->
I love TextMate and use it for a variety of tasks, including the creation of HTML pages, BUT, I miss BBEdit's bbinclude functionality.
Is there anyway to recreate this functionality in TextMate? I'm currently using simple snippets with tab triggers to mimic a portion of this functionality but sometimes I'd like to update multiple sections of an HTML file at once and tab-triggered snippets are not sufficient to address that need. In addition, I'd love to have the ability to update all the HTML files contained within a TextMate project with one command. Possible?
Suggestions / feedback would be greatly appreciated!
Thanks,
Ken
On 1/8/2006, at 23:53, Ken Anderson wrote:
[...] Is there anyway to recreate this functionality in TextMate?
Yes -- the bbinclude sounds like just a preprocessor and OS X ships with several, like ERb allowing <% embedded ruby %> and PHP which allows <?php … >.
So you would setup a command to run your files through that preprocessor and store the result where you find it fitting. I give an example here [1].
[1] http://lists.macromates.com/pipermail/textmate/2006-March/ 008844.html
On Aug 2, 2006, at 11:11 AM, Allan Odgaard wrote:
On 1/8/2006, at 23:53, Ken Anderson wrote:
[...] Is there anyway to recreate this functionality in TextMate?
Yes -- the bbinclude sounds like just a preprocessor and OS X ships with several, like ERb allowing <% embedded ruby %> and PHP which allows <?php … >.
Different style of working. The difference is that #bbinclude modifies the file in place, and you can update the same file over and over again.
Chris
Hi Ken,
I've checked in the first pass at supporting this feature. It's in HTML bundle in the macromates.com subversion repository.
Usage: In an HTML document, either use cmd+ctrl+i (include) to insert the include markup, or just type it out... like this:
<!-- #tminclude "/path/to/file" --> <!-- end tminclude -->
(bbinclude works too, but I thought this was more appropriate.)
To update, use cmd+ctrl+u (same as in BBEdit). This will pull in the included file, but leaves the include markup. Re-running the update command will refresh the includes, as you'd expect.
It's recursive, like BBEdit... so included files can include files or contain placeholders. It also supports running Perl/Python/Ruby scripts (include the script... it must be executable though and must end in a .pl/.py/.rb extension to be recognized; I'll probably make this more generic by sniffing the first line for a shebang). Sorry... no support for AppleScript yet. The parameters passed to the script match the interface BBEdit uses (so command line arguments are: <source_file_name> <arg> <value> <arg2> <value2> ......". All TM_* variables are also passed through, since this is a TM command subprocess.
Most of the BBEdit placeholders are supported; a few are not... notably the ones defined through the "web project" dialog. But it does automatically support all the "TM_*" variables (but you omit the "TM_" prefix). So you can say: #organization_name# to output the value of the TM_ORGANIZATION_NAME environment variable. Placeholder names are case-insensitive.
It also supports parameters for includes, as BBEdit does. So you may say:
<!-- #tminclude "/path/to/header.inc" #title#="Title For Include" --> <!-- end tminclude -->
So, your header.inc file could have...
<title>#title#</title>
And it would expand as you'd expect.
The path for include files can be relative. If it is relative, the update command will look for it, relative to 1) the current file, 2) the project directory (if invoked within a project). You can also use "~/path/to/file" and it will expand that to the path relative to your home directory. Oh, that reminds me... the file path is specified using posix paths (/path/to/file) instead of the legacy Mac form ("Drive:Folder:Folder:File"). I'd like to support the legacy form for backward-compatibility, but I recommend using posix paths in general.
I'll take a look at supporting the "update all files in project" feature (or even selected files in the project drawer). Both should certainly be possible.
-Brad
PS: Oh and currently, there's nothing to prevent you from shooting yourself in the foot with including a file that includes itself... I'll take care of that shortly.
On Aug 1, 2006, at 2:53 PM, Ken Anderson wrote:
Hi,
After a quick search of the TextMate Wiki and archives of this list, I am writing to ask about TextMate's ability to support a useful feature related to BBEdit's support for creating websites.
In particular, BBEdit has a feature called "bbinclude" that allows one to insert statements like
<!-- #bbinclude "footer.html" -->
<!-- end bbinclude -->
into an HTML file. You can then "update" the host file and BBEdit pulls in the text from the referenced file and includes it in the host file.
For instance, my footer.html file looks like this:
<div id="footer"> <p>© Kenneth M. Anderson, 1998-#YEARNUM#.</p> <p>Last Updated: #SHORTDATE#; #TIME#</p> </div>
and when I run the update command, it generates text like this:
<!-- #bbinclude "footer.html" -->
<div id="footer"> <p>© Kenneth M. Anderson, 1998-2006.</p> <p>Last Updated: 08/01/06; 3:43 PM</p> </div>
<!-- end bbinclude -->
I love TextMate and use it for a variety of tasks, including the creation of HTML pages, BUT, I miss BBEdit's bbinclude functionality.
Is there anyway to recreate this functionality in TextMate? I'm currently using simple snippets with tab triggers to mimic a portion of this functionality but sometimes I'd like to update multiple sections of an HTML file at once and tab-triggered snippets are not sufficient to address that need. In addition, I'd love to have the ability to update all the HTML files contained within a TextMate project with one command. Possible?
Suggestions / feedback would be greatly appreciated!
Thanks,
Ken
On Aug 3, 2006, at 1:35 AM, Brad Choate wrote:
I've checked in the first pass at supporting this feature.
What you have built here is just terrific!
It's in HTML bundle in the macromates.com subversion repository.
Would you be open the the idea of pulling the comment character from TM's environment and moving this feature to the Source bundle? Seems like it could be useful in just about any language that way.
I'm happy to do the patch for that, if you are interested. Just let me know.
James Edward Gray II
On 3/8/2006, at 15:34, James Edward Gray II wrote:
It's in HTML bundle in the macromates.com subversion repository.
Would you be open the the idea of pulling the comment character from TM's environment and moving this feature to the Source bundle? Seems like it could be useful in just about any language that way.
One problem will be with an “Update All Files in Project” as the comment characters are only available for the current scope.
In practice it could also be a problem with mixed documents, e.g. if you fire the “Update” inside some embedded CSS or JavaScript, you will get the wrong characters.
But I like the idea… seems TM’s language parser should really be made available “outside” TextMate.
On Aug 4, 2006, at 10:34 AM, Allan Odgaard wrote:
On 3/8/2006, at 15:34, James Edward Gray II wrote:
It's in HTML bundle in the macromates.com subversion repository.
Would you be open the the idea of pulling the comment character from TM's environment and moving this feature to the Source bundle? Seems like it could be useful in just about any language that way.
One problem will be with an “Update All Files in Project” as the comment characters are only available for the current scope.
In practice it could also be a problem with mixed documents, e.g. if you fire the “Update” inside some embedded CSS or JavaScript, you will get the wrong characters.
I don't think these will be much on an issue. We can just scan for lines with tminclude somewhere in them, being liberal about the comments we accept before and after that.
James Edward Gray II
I had thought of generalizing it further... but what other documents would be likely to use it? Most scripting languages should be using their native include/require commands instead of something like this, IMHO.
-Brad
On Aug 3, 2006, at 6:34 AM, James Edward Gray II wrote:
On Aug 3, 2006, at 1:35 AM, Brad Choate wrote:
I've checked in the first pass at supporting this feature.
What you have built here is just terrific!
It's in HTML bundle in the macromates.com subversion repository.
Would you be open the the idea of pulling the comment character from TM's environment and moving this feature to the Source bundle? Seems like it could be useful in just about any language that way.
I'm happy to do the patch for that, if you are interested. Just let me know.
James Edward Gray II
On Aug 4, 2006, at 11:53 AM, Brad Choate wrote:
I had thought of generalizing it further... but what other documents would be likely to use it? Most scripting languages should be using their native include/require commands instead of something like this, IMHO.
Hmm, you do have a very good point there. Perhaps it isn't needed.
James Edward Gray II
I had thought of generalizing it further... but what other documents would be likely to use it? Most scripting languages should be using their native include/require commands instead of something like this, IMHO.
Hmm, you do have a very good point there. Perhaps it isn't needed.
However, something like this may be useful when writing code in a less flexible language and using scripting to help get around some of the repetition that is sometimes necessary...
Matthew
Do you have a specific language in mind or is this just theoretical?
On Aug 5, 2006, at 6:40 AM, Matthew Johnson wrote:
I had thought of generalizing it further... but what other documents would be likely to use it? Most scripting languages should be using their native include/require commands instead of something like this, IMHO.
Hmm, you do have a very good point there. Perhaps it isn't needed.
However, something like this may be useful when writing code in a less flexible language and using scripting to help get around some of the repetition that is sometimes necessary...
Matthew
Brad Choate <bchoate@...> writes:
Do you have a specific language in mind or is this just theoretical?
I am planning to use Ruby to augment some of the .NET development I'm still stuck doing at work. It also could be helpful for some things in Cocoa development (which I am planning to pick up again at some point) such as \ accessor definitions . The part that makes this worthwhile is the ability to include the output of a script.
Matthew
On 5 Aug 2006, at 04:29, James Edward Gray II wrote:
On Aug 4, 2006, at 11:53 AM, Brad Choate wrote:
I had thought of generalizing it further... but what other documents would be likely to use it? Most scripting languages should be using their native include/require commands instead of something like this, IMHO.
Hmm, you do have a very good point there. Perhaps it isn't needed.
James Edward Gray II
It would be useful for Markdown documents.
Best, Mark
On Aug 6, 2006, at 1:54 PM, Mark Eli Kalderon wrote:
On 5 Aug 2006, at 04:29, James Edward Gray II wrote:
On Aug 4, 2006, at 11:53 AM, Brad Choate wrote:
I had thought of generalizing it further... but what other documents would be likely to use it? Most scripting languages should be using their native include/require commands instead of something like this, IMHO.
Hmm, you do have a very good point there. Perhaps it isn't needed.
James Edward Gray II
It would be useful for Markdown documents.
Does Markdown have a comment character we could hide the identifiers in?
James Edward Gray II
On 6 Aug 2006, at 19:59, James Edward Gray II wrote:
On Aug 6, 2006, at 1:54 PM, Mark Eli Kalderon wrote:
On 5 Aug 2006, at 04:29, James Edward Gray II wrote:
On Aug 4, 2006, at 11:53 AM, Brad Choate wrote:
I had thought of generalizing it further... but what other documents would be likely to use it? Most scripting languages should be using their native include/require commands instead of something like this, IMHO.
Hmm, you do have a very good point there. Perhaps it isn't needed.
James Edward Gray II
It would be useful for Markdown documents.
Does Markdown have a comment character we could hide the identifiers in?
James Edward Gray II
Not per se, but since it accepts embedded html, you can always use html comments.
Best, Mark
On Aug 6, 2006, at 2:15 PM, Mark Eli Kalderon wrote:
On 6 Aug 2006, at 19:59, James Edward Gray II wrote:
On Aug 6, 2006, at 1:54 PM, Mark Eli Kalderon wrote:
On 5 Aug 2006, at 04:29, James Edward Gray II wrote:
On Aug 4, 2006, at 11:53 AM, Brad Choate wrote:
I had thought of generalizing it further... but what other documents would be likely to use it? Most scripting languages should be using their native include/require commands instead of something like this, IMHO.
Hmm, you do have a very good point there. Perhaps it isn't needed.
James Edward Gray II
It would be useful for Markdown documents.
Does Markdown have a comment character we could hide the identifiers in?
James Edward Gray II
Not per se, but since it accepts embedded html, you can always use html comments.
Then I bet the commands already work there. ;)
James Edward Gray II
On 6 Aug 2006, at 20:34, James Edward Gray II wrote:
On Aug 6, 2006, at 2:15 PM, Mark Eli Kalderon wrote:
On 6 Aug 2006, at 19:59, James Edward Gray II wrote:
On Aug 6, 2006, at 1:54 PM, Mark Eli Kalderon wrote:
On 5 Aug 2006, at 04:29, James Edward Gray II wrote:
On Aug 4, 2006, at 11:53 AM, Brad Choate wrote:
I had thought of generalizing it further... but what other documents would be likely to use it? Most scripting languages should be using their native include/require commands instead of something like this, IMHO.
Hmm, you do have a very good point there. Perhaps it isn't needed.
James Edward Gray II
It would be useful for Markdown documents.
Does Markdown have a comment character we could hide the identifiers in?
James Edward Gray II
Not per se, but since it accepts embedded html, you can always use html comments.
Then I bet the commands already work there. ;)
James Edward Gray II
You are right! Too cool.
Best, Mark
On 5 aug 2006, at 05.29, James Edward Gray II wrote:
On Aug 4, 2006, at 11:53 AM, Brad Choate wrote:
I had thought of generalizing it further... but what other documents would be likely to use it? Most scripting languages should be using their native include/require commands instead of something like this, IMHO.
Hmm, you do have a very good point there. Perhaps it isn't needed.
I would certainly find very good use for it in both LaTeX and Matlab. There are ways to call other files, but often I need to deliver everything in one file. Oh, I'd love it!
BTW, the BBEdit placeholder #relative# is ignored?
/Peder Axensten
The #relative# placeholder is supported now, with the latest version of the HTML bundle from macromates.com's subversion repository. The placeholder assumes the root of your project directory is the root of your site, for relative location. So if your project looks like this:
about/ index.html images/ logo.jpg tmpl/ header.ttmpl
And you have an index.html file in the 'about' directory, that says...
<!-- tminclude file="tmpl/header.tmpl" #title#="About Us..." -->
With header.tmpl under the 'tmpl' directory containing this...
<img src="#relative#images/logo.jpg" class="logo" /> <h2>#title#</h2>
That would expand within the index.html file as
<img src="../images/logo.jpg" class="logo" /> <h2>About Us...</h2>
-Brad
On Aug 7, 2006, at 12:21 PM, Peder Axensten wrote:
On 5 aug 2006, at 05.29, James Edward Gray II wrote:
On Aug 4, 2006, at 11:53 AM, Brad Choate wrote:
I had thought of generalizing it further... but what other documents would be likely to use it? Most scripting languages should be using their native include/require commands instead of something like this, IMHO.
Hmm, you do have a very good point there. Perhaps it isn't needed.
I would certainly find very good use for it in both LaTeX and Matlab. There are ways to call other files, but often I need to deliver everything in one file. Oh, I'd love it!
BTW, the BBEdit placeholder #relative# is ignored?
/Peder Axensten
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
A month later I pick up the thread...
Firstly: I'm very glad to see persistent includes in TextMate!! Thanks!! Will there be a way to update a whole site, e.g. all files in a certain directory?
There are a couple of things I can't get to work. I have the latest cutting edge TextMate version, do I also need some extra bundle or something?
I get persistant includes to work as long as I have a relative path from the source directory to the template, but not if I start from the project directory. In the case quoted below I get an error that there is no "<from root>/about/tmpl/header.tmpl" -- it starts the relative path from the soure's directory, not from the project directory. What am I missing?
And the #relative# marker is left untouched even when I make the template found? E.g., #localtime %Y-%m-%e# does work.
Any help appreciated!
On 9 aug 2006, at 01.24, Brad Choate wrote:
The #relative# placeholder is supported now, with the latest version of the HTML bundle from macromates.com's subversion repository. The placeholder assumes the root of your project directory is the root of your site, for relative location. So if your project looks like this:
about/ index.html images/ logo.jpg tmpl/ header.ttmpl
And you have an index.html file in the 'about' directory, that says...
<!-- tminclude file="tmpl/header.tmpl" #title#="About Us..." -->
With header.tmpl under the 'tmpl' directory containing this...
<img src="#relative#images/logo.jpg" class="logo" /> <h2>#title#</h2>
That would expand within the index.html file as
<img src="../images/logo.jpg" class="logo" /> <h2>About Us...</h2>
I've just checked in support for whatever comment delimiters that are supported by the language of the file being edited. So... for instance, in a LaTeX document, you can say...
% #tminclude "/path/to/include" % end tminclude
Or, in a CSS document...
/* #tminclude "/path/to/include" */ /* end tminclude */
The placeholder syntax itself is the same for all documents... "#name#"
For now, the include/update commands are still bound to the HTML bundle, but that may change if this becomes more popular I suppose. You can select it manually through the HTML bundle, or use the cmd +ctrl+t "select bundle item" window to find the commands (type "API" or "UPDOC" in caps to find these commands irrespective of the active scope).
-Brad
On Aug 7, 2006, at 12:21 PM, Peder Axensten wrote:
On 5 aug 2006, at 05.29, James Edward Gray II wrote:
On Aug 4, 2006, at 11:53 AM, Brad Choate wrote:
I had thought of generalizing it further... but what other documents would be likely to use it? Most scripting languages should be using their native include/require commands instead of something like this, IMHO.
Hmm, you do have a very good point there. Perhaps it isn't needed.
I would certainly find very good use for it in both LaTeX and Matlab. There are ways to call other files, but often I need to deliver everything in one file. Oh, I'd love it!
BTW, the BBEdit placeholder #relative# is ignored?
/Peder Axensten
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Hi Brad,
Wow! Thanks for responding to my request so quickly!
I updated my version of the HTML bundle using subversion and I do indeed see the "Includes" menu and the two items that it contains.
When I manually type the include markup and invoke the update command, things work as expected. (Thanks again! I can't tell you how happy I am to see this functionality in TextMate!)
I did run into one problem with using the "Add persistent include" command, however. When I run it, I get the following error message:
/Library/Application Support/TextMate/Bundles/HTML.tmbundle/Support/ tminclude.rb:227:in `include_command': undefined method `request_file' for Dialog:Module (NoMethodError) from /tmp/temp_textmate.cR7Nlx:3
I suspect I need to update some other portion of TextMate to avoid this error. Currently, in my </Library/Application Support/TextMate> directory, I only have one subdirectory "Bundles".
What else do I need to check out from Subversion to get this to work?
Thanks again!
Ken
On Aug 3, 2006, at 12:35 AM, Brad Choate wrote:
Hi Ken,
I've checked in the first pass at supporting this feature. It's in HTML bundle in the macromates.com subversion repository.
Usage: In an HTML document, either use cmd+ctrl+i (include) to insert the include markup, or just type it out... like this:
<!-- #tminclude "/path/to/file" -->
<!-- end tminclude -->
(bbinclude works too, but I thought this was more appropriate.)
To update, use cmd+ctrl+u (same as in BBEdit). This will pull in the included file, but leaves the include markup. Re-running the update command will refresh the includes, as you'd expect.
It's recursive, like BBEdit... so included files can include files or contain placeholders. It also supports running Perl/Python/Ruby scripts (include the script... it must be executable though and must end in a .pl/.py/.rb extension to be recognized; I'll probably make this more generic by sniffing the first line for a shebang). Sorry... no support for AppleScript yet. The parameters passed to the script match the interface BBEdit uses (so command line arguments are: <source_file_name> <arg> <value> <arg2> <value2> ......". All TM_* variables are also passed through, since this is a TM command subprocess.
Most of the BBEdit placeholders are supported; a few are not... notably the ones defined through the "web project" dialog. But it does automatically support all the "TM_*" variables (but you omit the "TM_" prefix). So you can say: #organization_name# to output the value of the TM_ORGANIZATION_NAME environment variable. Placeholder names are case-insensitive.
It also supports parameters for includes, as BBEdit does. So you may say:
<!-- #tminclude "/path/to/header.inc" #title#="Title For Include" -->
<!-- end tminclude -->
So, your header.inc file could have...
<title>#title#</title>
And it would expand as you'd expect.
The path for include files can be relative. If it is relative, the update command will look for it, relative to 1) the current file, 2) the project directory (if invoked within a project). You can also use "~/path/to/file" and it will expand that to the path relative to your home directory. Oh, that reminds me... the file path is specified using posix paths (/path/to/file) instead of the legacy Mac form ("Drive:Folder:Folder:File"). I'd like to support the legacy form for backward-compatibility, but I recommend using posix paths in general.
I'll take a look at supporting the "update all files in project" feature (or even selected files in the project drawer). Both should certainly be possible.
-Brad
PS: Oh and currently, there's nothing to prevent you from shooting yourself in the foot with including a file that includes itself... I'll take care of that shortly.
On Aug 1, 2006, at 2:53 PM, Ken Anderson wrote:
Hi,
After a quick search of the TextMate Wiki and archives of this list, I am writing to ask about TextMate's ability to support a useful feature related to BBEdit's support for creating websites.
In particular, BBEdit has a feature called "bbinclude" that allows one to insert statements like
<!-- #bbinclude "footer.html" -->
<!-- end bbinclude -->
into an HTML file. You can then "update" the host file and BBEdit pulls in the text from the referenced file and includes it in the host file.
For instance, my footer.html file looks like this:
<div id="footer"> <p>© Kenneth M. Anderson, 1998-#YEARNUM#.</p> <p>Last Updated: #SHORTDATE#; #TIME#</p> </div>
and when I run the update command, it generates text like this:
<!-- #bbinclude "footer.html" -->
<div id="footer"> <p>© Kenneth M. Anderson, 1998-2006.</p> <p>Last Updated: 08/01/06; 3:43 PM</p> </div>
<!-- end bbinclude -->
I love TextMate and use it for a variety of tasks, including the creation of HTML pages, BUT, I miss BBEdit's bbinclude functionality.
Is there anyway to recreate this functionality in TextMate? I'm currently using simple snippets with tab triggers to mimic a portion of this functionality but sometimes I'd like to update multiple sections of an HTML file at once and tab-triggered snippets are not sufficient to address that need. In addition, I'd love to have the ability to update all the HTML files contained within a TextMate project with one command. Possible?
Suggestions / feedback would be greatly appreciated!
Thanks,
Ken
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Hi,
On Aug 4, 2006, at 9:31 AM, Allan Odgaard wrote:
On 3/8/2006, at 18:14, Ken Anderson wrote:
[...] What else do I need to check out from Subversion to get this to work?
The support folder -- however if you upgrade to latest version of TM it has the updated folder included (so will work out of the box.)
I downloaded the update and can confirm that everything is now working.
Ken.status = "Happy As A Clam";
Thanks Brad and Allan for the incredibly fast response to this feature request. I was a happy TextMate user before this, but now you've turned me into an evangelist! :-)
Ken
You'll also need to either checkout the "Support" directory from the Macromates SVN repository, or upgrade to the latest "Cutting Edge" release of TextMate (build 1197) which includes the updates I made for that particular method.
-Brad
On Aug 3, 2006, at 9:14 AM, Ken Anderson wrote:
Hi Brad,
Wow! Thanks for responding to my request so quickly!
I updated my version of the HTML bundle using subversion and I do indeed see the "Includes" menu and the two items that it contains.
When I manually type the include markup and invoke the update command, things work as expected. (Thanks again! I can't tell you how happy I am to see this functionality in TextMate!)
I did run into one problem with using the "Add persistent include" command, however. When I run it, I get the following error message:
/Library/Application Support/TextMate/Bundles/HTML.tmbundle/Support/ tminclude.rb:227:in `include_command': undefined method `request_file' for Dialog:Module (NoMethodError) from /tmp/temp_textmate.cR7Nlx:3
I suspect I need to update some other portion of TextMate to avoid this error. Currently, in my </Library/Application Support/ TextMate> directory, I only have one subdirectory "Bundles".
What else do I need to check out from Subversion to get this to work?
Thanks again!
Ken
On Aug 3, 2006, at 12:35 AM, Brad Choate wrote:
Hi Ken,
I've checked in the first pass at supporting this feature. It's in HTML bundle in the macromates.com subversion repository.
Usage: In an HTML document, either use cmd+ctrl+i (include) to insert the include markup, or just type it out... like this:
<!-- #tminclude "/path/to/file" -->
<!-- end tminclude -->
(bbinclude works too, but I thought this was more appropriate.)
To update, use cmd+ctrl+u (same as in BBEdit). This will pull in the included file, but leaves the include markup. Re-running the update command will refresh the includes, as you'd expect.
It's recursive, like BBEdit... so included files can include files or contain placeholders. It also supports running Perl/Python/ Ruby scripts (include the script... it must be executable though and must end in a .pl/.py/.rb extension to be recognized; I'll probably make this more generic by sniffing the first line for a shebang). Sorry... no support for AppleScript yet. The parameters passed to the script match the interface BBEdit uses (so command line arguments are: <source_file_name> <arg> <value> <arg2> <value2> ......". All TM_* variables are also passed through, since this is a TM command subprocess.
Most of the BBEdit placeholders are supported; a few are not... notably the ones defined through the "web project" dialog. But it does automatically support all the "TM_*" variables (but you omit the "TM_" prefix). So you can say: #organization_name# to output the value of the TM_ORGANIZATION_NAME environment variable. Placeholder names are case-insensitive.
It also supports parameters for includes, as BBEdit does. So you may say:
<!-- #tminclude "/path/to/header.inc" #title#="Title For Include" -->
<!-- end tminclude -->
So, your header.inc file could have...
<title>#title#</title>
And it would expand as you'd expect.
The path for include files can be relative. If it is relative, the update command will look for it, relative to 1) the current file, 2) the project directory (if invoked within a project). You can also use "~/path/to/file" and it will expand that to the path relative to your home directory. Oh, that reminds me... the file path is specified using posix paths (/path/to/file) instead of the legacy Mac form ("Drive:Folder:Folder:File"). I'd like to support the legacy form for backward-compatibility, but I recommend using posix paths in general.
I'll take a look at supporting the "update all files in project" feature (or even selected files in the project drawer). Both should certainly be possible.
-Brad
PS: Oh and currently, there's nothing to prevent you from shooting yourself in the foot with including a file that includes itself... I'll take care of that shortly.
On Aug 1, 2006, at 2:53 PM, Ken Anderson wrote:
Hi,
After a quick search of the TextMate Wiki and archives of this list, I am writing to ask about TextMate's ability to support a useful feature related to BBEdit's support for creating websites.
In particular, BBEdit has a feature called "bbinclude" that allows one to insert statements like
<!-- #bbinclude "footer.html" -->
<!-- end bbinclude -->
into an HTML file. You can then "update" the host file and BBEdit pulls in the text from the referenced file and includes it in the host file.
For instance, my footer.html file looks like this:
<div id="footer"> <p>© Kenneth M. Anderson, 1998-#YEARNUM#.</p> <p>Last Updated: #SHORTDATE#; #TIME#</p> </div>
and when I run the update command, it generates text like this:
<!-- #bbinclude "footer.html" -->
<div id="footer"> <p>© Kenneth M. Anderson, 1998-2006.</p> <p>Last Updated: 08/01/06; 3:43 PM</p> </div>
<!-- end bbinclude -->
I love TextMate and use it for a variety of tasks, including the creation of HTML pages, BUT, I miss BBEdit's bbinclude functionality.
Is there anyway to recreate this functionality in TextMate? I'm currently using simple snippets with tab triggers to mimic a portion of this functionality but sometimes I'd like to update multiple sections of an HTML file at once and tab-triggered snippets are not sufficient to address that need. In addition, I'd love to have the ability to update all the HTML files contained within a TextMate project with one command. Possible?
Suggestions / feedback would be greatly appreciated!
Thanks,
Ken
_ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
-- Kenneth M. Anderson | Phone: 303-492-6003 Associate Professor | Fax : 303-492-2844 Dept. of Computer Science | mailto:kena@cs.colorado.edu University of Colorado, Boulder | http://www.cs.colorado.edu/~kena/
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate