You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by xak <zf...@vsapartners.com> on 2009/04/30 20:54:24 UTC

Need help with REPLACING an SSI directive

First off, I am very new to using ANT and I'n not a Java developer but my
needs are very simple ... 

I am creating a web site that is decently large but it must be static. So
I'm thinking that I can develop the site locally using server-side includes
to avoid hardcoding all the navigation, etc. and then "publish" the site
using ANT where all the SSIs are replaced with the actual file contents.

Replacing a token is easy enough but I don't know how to "regex" the comment
syntax of the SSIs. Is that even the right approach? Can I use replace or do
I need something else?

This is in the SSI syntax in the HTML:
  <!--#include file="_includes/_html_head_open.html" -->

I need to replace with ${html.head.open} as defined below:
   <loadfile property="html.head.open"
srcFile="${src}/_includes/_html_head_open.html" />

So I need something like this where the token is the SSI:
   <replace dir="${output}" token="@html.head.open@"
value="${html.head.open}" /> 

The most important thing here is to be able to develop the source files,
view them in the browser and then only at the end do a publish build where
the SSIs are replaced. That's it.

I know there are ANT tasks out there to turn various template markup into
HTML but that is overkill for my needs.

Any assistance will be greatly appreciated.

Zack
-- 
View this message in context: http://www.nabble.com/Need-help-with-REPLACING-an-SSI-directive-tp23322263p23322263.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Need help with REPLACING an SSI directive

Posted by xak <zf...@vsapartners.com>.

Yeah, that is exactly what I want to do. Just somehow recognize the SSI
string in the HTML and then replace it with the actual file contents. 

I thought ANT would be nice because there are other tasks as part of the
publishing -- copying all files to new directories, concatenating CSS files,
compressing JavaScript files, etc. I guess PERL or Python would work with
all that too but I don't know those languages. ANT seemed more accessible
even if not totally appropriate.

Worst case, I can embed tokens in the HTML next to the SSIs, replace the
tokens, and then strip out the comments. But then I have the tokens visible
when working in SSI-mode. Not the worst thing in the world but I figured
there should be a way.

Thanks. Maybe I'll dive into another scripting option.

Zack



David Weintraub wrote:
> 
> I'm trying to figure out exactly what you need. You want to *insert*
> the file the ServerSide Include is referring to instead of using
> Server Side Includes?
> 
> I would think Ant would be an overkill in this case. A simple Perl or
> Python script would do exactly what you want and shouldn't take long
> to do.
> 
> The filter is mainly for replacing strings and not including whole
> files into other files.
> 
> On Thu, Apr 30, 2009 at 2:54 PM, xak <zf...@vsapartners.com> wrote:
>>
>> First off, I am very new to using ANT and I'n not a Java developer but my
>> needs are very simple ...
>>
>> I am creating a web site that is decently large but it must be static. So
>> I'm thinking that I can develop the site locally using server-side
>> includes
>> to avoid hardcoding all the navigation, etc. and then "publish" the site
>> using ANT where all the SSIs are replaced with the actual file contents.
>>
>> Replacing a token is easy enough but I don't know how to "regex" the
>> comment
>> syntax of the SSIs. Is that even the right approach? Can I use replace or
>> do
>> I need something else?
>>
>> This is in the SSI syntax in the HTML:
>>  <!--#include file="_includes/_html_head_open.html" -->
>>
>> I need to replace with ${html.head.open} as defined below:
>>   <loadfile property="html.head.open"
>> srcFile="${src}/_includes/_html_head_open.html" />
>>
>> So I need something like this where the token is the SSI:
>>   <replace dir="${output}" token="@html.head.open@"
>> value="${html.head.open}" />
>>
>> The most important thing here is to be able to develop the source files,
>> view them in the browser and then only at the end do a publish build
>> where
>> the SSIs are replaced. That's it.
>>
>> I know there are ANT tasks out there to turn various template markup into
>> HTML but that is overkill for my needs.
>>
>> Any assistance will be greatly appreciated.
>>
>> Zack
>> --
>> View this message in context:
>> http://www.nabble.com/Need-help-with-REPLACING-an-SSI-directive-tp23322263p23322263.html
>> Sent from the Ant - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
> 
> 
> 
> -- 
> David Weintraub
> qazwart@gmail.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Need-help-with-REPLACING-an-SSI-directive-tp23322263p23325209.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Need help with REPLACING an SSI directive

Posted by David Weintraub <qa...@gmail.com>.
I'm trying to figure out exactly what you need. You want to *insert*
the file the ServerSide Include is referring to instead of using
Server Side Includes?

I would think Ant would be an overkill in this case. A simple Perl or
Python script would do exactly what you want and shouldn't take long
to do.

The filter is mainly for replacing strings and not including whole
files into other files.

On Thu, Apr 30, 2009 at 2:54 PM, xak <zf...@vsapartners.com> wrote:
>
> First off, I am very new to using ANT and I'n not a Java developer but my
> needs are very simple ...
>
> I am creating a web site that is decently large but it must be static. So
> I'm thinking that I can develop the site locally using server-side includes
> to avoid hardcoding all the navigation, etc. and then "publish" the site
> using ANT where all the SSIs are replaced with the actual file contents.
>
> Replacing a token is easy enough but I don't know how to "regex" the comment
> syntax of the SSIs. Is that even the right approach? Can I use replace or do
> I need something else?
>
> This is in the SSI syntax in the HTML:
>  <!--#include file="_includes/_html_head_open.html" -->
>
> I need to replace with ${html.head.open} as defined below:
>   <loadfile property="html.head.open"
> srcFile="${src}/_includes/_html_head_open.html" />
>
> So I need something like this where the token is the SSI:
>   <replace dir="${output}" token="@html.head.open@"
> value="${html.head.open}" />
>
> The most important thing here is to be able to develop the source files,
> view them in the browser and then only at the end do a publish build where
> the SSIs are replaced. That's it.
>
> I know there are ANT tasks out there to turn various template markup into
> HTML but that is overkill for my needs.
>
> Any assistance will be greatly appreciated.
>
> Zack
> --
> View this message in context: http://www.nabble.com/Need-help-with-REPLACING-an-SSI-directive-tp23322263p23322263.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>



-- 
David Weintraub
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Need help with REPLACING an SSI directive

Posted by Francis Galiegue <fg...@one2team.com>.
Le Thursday 30 April 2009 20:54:24 xak, vous avez écrit :
> First off, I am very new to using ANT and I'n not a Java developer but my
> needs are very simple ...
>
> I am creating a web site that is decently large but it must be static. So
> I'm thinking that I can develop the site locally using server-side includes
> to avoid hardcoding all the navigation, etc. and then "publish" the site
> using ANT where all the SSIs are replaced with the actual file contents.
>
> Replacing a token is easy enough but I don't know how to "regex" the
> comment syntax of the SSIs. Is that even the right approach? Can I use
> replace or do I need something else?
>
> This is in the SSI syntax in the HTML:
>   <!--#include file="_includes/_html_head_open.html" -->
>
> I need to replace with ${html.head.open} as defined below:
>    <loadfile property="html.head.open"
> srcFile="${src}/_includes/_html_head_open.html" />
>
> So I need something like this where the token is the SSI:
>    <replace dir="${output}" token="@html.head.open@"
> value="${html.head.open}" />
>
> The most important thing here is to be able to develop the source files,
> view them in the browser and then only at the end do a publish build where
> the SSIs are replaced. That's it.
>
> I know there are ANT tasks out there to turn various template markup into
> HTML but that is overkill for my needs.
>
> Any assistance will be greatly appreciated.
>
> Zack

Does the base file has a template? Say, you have a template HTML file, which 
reads, somewhere:

<!--#include file="${src}/_includes/_html_head_open.html"/>

Then you can do:

<copy overwrite="true" file="/place/where/the/template/is"
	tofile="/the/definitive/place">
	<filterset>
		<filter token="src" begintoken="$${" endtoken="}"
			value="thevalueyouwantfor$srchere"/>
	</filterset>
</copy>

Even better, if the value for src is defined as a property in a file 
somewhere, you can do:

<copy overwrite="true" file="/place/where/the/template/is"
	tofile="/the/definitive/place">
	<filterset begintoken="$${" endtoken="}"
		filtersfile="/path/to/the/file/where/src/is/defined">
</copy>

-- 
Francis Galiegue
fge@one2team.com
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
One2team
40 avenue Raymond Poincaré
75116 Paris

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org