[TxMt] Recreating bbinclude in TextMate?
Brad Choate
bchoate at gmail.com
Fri Aug 4 16:51:32 UTC 2006
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 at 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 at cs.colorado.edu>
> University of Colorado, Boulder | <http://www.cs.colorado.edu/~kena/>
>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate
More information about the textmate
mailing list