[TxMt] Persistent Includes?
Eric O'Brien
ericob at possibilityengine.com
Sat Mar 4 23:57:31 UTC 2006
This is a neat approach but I see some limitations in it if I were to
try to use it in the way I envision working. That is, I have a wish
list! :)
As near as I can understand this code, it starts in the current
TextMate project directory, creating a new directory there named
"html." It then goes through the project directory looking for files
that end in ".php," hands those files to the php command line
interpreter and puts the output into the previously created "html"
directory, changing the file extension from ".php" to ".html."
I assume it does this recursively both when searching for php files
and when outputting the files as html. I think the -p switch will
cause that to happen on the output side, but I'm not clear where it
happens in the for...do part.
I don't see that this will create a complete site, though. That is,
there are many other kinds of files (css files, image, movie and
sound files, etc.) in my working site (my TM project). Naturally,
those would need to get moved into their correct locations in the new
(static) "html" folder also.
Next challenge: this process (ejecting a static version of my
dynamic working site) is not something that I would do once, at the
"end" of a project, but quite often... whenever I wanted to publish
the site to a test or staging server. In that situation, I certainly
don't want to have to process every file for the entire site each
time I want to update my test server. I only want to process the
files that have *changed* since the last time I ran the process.
Conceptually, I sorta would like to work rsync into the process here,
but I don't quite see how to do it (as none of the html files in the
static site are going to match with their "source" php files).
Thanks for any ideas!
eo
On Mar 3, 2006, at 8:29 AM, Allan Odgaard wrote:
> On 2/3/2006, at 15:30, csilver_junk at mac.com wrote:
>
>> [...] If nothing resembling Persistent Includes is available in
>> TextMate, another viable option would be to auto-generate the
>> output of an entire project but save it to a new directory on my
>> system using the same hierarchy of the original project [...]
>
> I have no real idea about what the Persistent Includes can do, but
> it would be easy to create a TM command which e.g. pipes each *.php
> file in your project through PHP and wrote the result to an “html”
> sub-directory (as an HTML file):
>
> cd "${TM_PROJECT_DIRECTORY:-$TM_DIRECTORY}"
> mkdir -p html
> for f in *.php; do
> php <"$f" >"html/${f%.*}.html"
> done
>
> This would allow you to use all the power of PHP and create static
> files from that. You could add a master.inc which got sourced when
> generating each of the files, e.g. like this:
>
> cd "${TM_PROJECT_DIRECTORY:-$TM_DIRECTORY}"
> mkdir -p html
> for f in *.php; do
> cat master.inc "$f"|php >"html/${f%.*}.html"
> done
>
> That way you could place shared variables and such in your master.inc.
>
> FYI the TextMate manual is generated in a slightly similar fashion,
> see http://lists.macromates.com/pipermail/textmate/2006-February/
> 008160.html for more.
More information about the textmate
mailing list