You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Paul Babachanakh <Pa...@uib.cherkassy.net> on 2003/10/13 14:39:16 UTC

Variables and Directives

Hello all!!!

I have tried to use Velocity Template Engine (version 1.3.1). It's
wonderful. But I have a problem and I don't understand how to resolve
it.

As a template file I'm using file in Rich Text Format from Microsoft
Word. And when I save it variables and directives may place
separately from sign $ or #. For example like this:

{\fs18\lang1049\langfe1049\langnp1049  $}{\fs18 dateB}

Variable dateB and $ place separately.

The question is: how can I configurate Velocity to replace $ and # to
something else?

Thank you for your time.

Sincerely,
Pavel Babachanakh
paul@uib.cherkassy.net


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Variables and Directives

Posted by Mike Kienenberger <mk...@alaska.net>.
Daniel Dekany <dd...@freemail.hu> wrote:
> Tuesday, October 14, 2003, 12:06:19 PM, Geir Magnusson Jr . wrote:
> 
> [snip]
> >> No. I can't. It will be very helpfull to setup sign for variables and
> >> directives in INI file.
> >
> > I guess it could - but that would mean that there is no one Velocity 
> > syntax.
> >
> > Interesting idea, though.
> [snip]
> 
> Template languages are a special category in this regard (wether the
> language syntax should be configurable or not). For other languages, we
> can say that multiple syntax just causes confusion, and anyway, who
> cares if you have to write $foo or @foo... this is just an arbitrary
> decision anyway. I heard this opinion about template languages as well.
> But, for template languages, it is important that the template language
> directives doesn't clash with the character sequences that often occur
> in the static text, and there are plenty of text formats around, not
> just HTML. So if I will ever write a general purpose template engine, it
> is pretty sure that its syntax will be highly configurable (pluggable
> Java parser + .propertyes file for the parsers written by me).

This is handled by the Objective-C MiscMergeKit template engine by having 
all variables and directives enclosed in a starting and ending tag.

Ie,  #if (x)# text #else# text #endif#

or ${if (x)} text ${else} text ${endif}


The actual starting and ending tags can at any point be changed using a 
#delimiters new-left-delimiter new-closing-delimiter # directive.


Ie,

## write html template info

#delimiters {$ $} #

write shell script template info

{$delimiters # # $}

write more html template info


I haven't found it all that useful to switch delimiters in the middle of a 
template, but I definitely have found it useful to switch delimiters at the 
start of a file.

The other nice thing about having directives with an ending tag is that you 
can have total control over whitespace for situations where whitespace 
really does matter without having to create a bunch of intermediate 
variables.



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Variables and Directives

Posted by Daniel Dekany <dd...@freemail.hu>.
Tuesday, October 14, 2003, 12:06:19 PM, Geir Magnusson Jr . wrote:

[snip]
>> No. I can't. It will be very helpfull to setup sign for variables and
>> directives in INI file.
>
> I guess it could - but that would mean that there is no one Velocity 
> syntax.
>
> Interesting idea, though.
[snip]

Template languages are a special category in this regard (wether the
language syntax should be configurable or not). For other languages, we
can say that multiple syntax just causes confusion, and anyway, who
cares if you have to write $foo or @foo... this is just an arbitrary
decision anyway. I heard this opinion about template languages as well.
But, for template languages, it is important that the template language
directives doesn't clash with the character sequences that often occur
in the static text, and there are plenty of text formats around, not
just HTML. So if I will ever write a general purpose template engine, it
is pretty sure that its syntax will be highly configurable (pluggable
Java parser + .propertyes file for the parsers written by me).

-- 
Best regards,
 Daniel Dekany



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Variables and Directives

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On Tuesday, October 14, 2003, at 05:24 AM, Paul Babachanakh wrote:

>>>>>> As a template file I'm using file in Rich Text Format from 
>>>>>> Microsoft
>>>>>> Word. And when I save it variables and directives may place
>>>>>> separately from sign $ or #. For example like this:
>>>>>>
>>>>>> {\fs18\lang1049\langfe1049\langnp1049  $}{\fs18 dateB}
>>>>>>
>>>>>> Variable dateB and $ place separately.
>>>>>>
>>>>>> The question is: how can I configurate Velocity to replace $ and #
>>>>>> to
>>>>>> something else?
>>>>> You can't, but why would you need to?  What is the problem?  (Sorry
>>>>> - I
>>>>> don't get from above what it is...)
>>>>
>>>> I think he's saying that when he saves the file it's inserting
>>>> formatting/RTF-ish info between the $ and variable name.
>>>>
>>>> I think.
>>> Thats right.
>>
>> Wow.  Oh, I see.  You are working in RTF and trying to put the
>> references in using the RTF editor.  That's probably hopeless.  Can 
>> you
>> edit the file after?
>>
> No. I can't. It will be very helpfull to setup sign for variables and
> directives in INI file.

I guess it could - but that would mean that there is no one Velocity 
syntax.

Interesting idea, though.

>
>
>>>>
>>>> Of course, using anything but a plain-text file as a template file 
>>>> is
>>>> probably not a Good Idea, as Word will undoubtedly spew into it and
>>>> change things around. Boo hiss.
>>>>
>>> I must use  Rich Text Format.
>>
>> Right - but can you do any post editing of the RTF file to prevent 
>> your
>> references and directives from being RTF-ed by the editor?
>>
>>
> This is very hard and inconvenient
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
>
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geirm@optonline.net


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Variables and Directives

Posted by Paul Babachanakh <Pa...@uib.cherkassy.net>.
> >>>> As a template file I'm using file in Rich Text Format from Microsoft
> >>>> Word. And when I save it variables and directives may place
> >>>> separately from sign $ or #. For example like this:
> >>>>
> >>>> {\fs18\lang1049\langfe1049\langnp1049  $}{\fs18 dateB}
> >>>>
> >>>> Variable dateB and $ place separately.
> >>>>
> >>>> The question is: how can I configurate Velocity to replace $ and #
> >>>> to
> >>>> something else?
> >>> You can't, but why would you need to?  What is the problem?  (Sorry
> >>> - I
> >>> don't get from above what it is...)
> >>
> >> I think he's saying that when he saves the file it's inserting
> >> formatting/RTF-ish info between the $ and variable name.
> >>
> >> I think.
> > Thats right.
>
> Wow.  Oh, I see.  You are working in RTF and trying to put the
> references in using the RTF editor.  That's probably hopeless.  Can you
> edit the file after?
>
No. I can't. It will be very helpfull to setup sign for variables and
directives in INI file.


> >>
> >> Of course, using anything but a plain-text file as a template file is
> >> probably not a Good Idea, as Word will undoubtedly spew into it and
> >> change things around. Boo hiss.
> >>
> > I must use  Rich Text Format.
>
> Right - but can you do any post editing of the RTF file to prevent your
> references and directives from being RTF-ed by the editor?
>
>
This is very hard and inconvenient


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Variables and Directives

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On Tuesday, October 14, 2003, at 01:49 AM, Paul Babachanakh wrote:

>> On Mon, 2003-10-13 at 14:19, Geir Magnusson Jr. wrote:
>>>> As a template file I'm using file in Rich Text Format from Microsoft
>>>> Word. And when I save it variables and directives may place
>>>> separately from sign $ or #. For example like this:
>>>>
>>>> {\fs18\lang1049\langfe1049\langnp1049  $}{\fs18 dateB}
>>>>
>>>> Variable dateB and $ place separately.
>>>>
>>>> The question is: how can I configurate Velocity to replace $ and # 
>>>> to
>>>> something else?
>>> You can't, but why would you need to?  What is the problem?  (Sorry 
>>> - I
>>> don't get from above what it is...)
>>
>> I think he's saying that when he saves the file it's inserting
>> formatting/RTF-ish info between the $ and variable name.
>>
>> I think.
> Thats right.

Wow.  Oh, I see.  You are working in RTF and trying to put the 
references in using the RTF editor.  That's probably hopeless.  Can you 
edit the file after?

>>
>> Of course, using anything but a plain-text file as a template file is
>> probably not a Good Idea, as Word will undoubtedly spew into it and
>> change things around. Boo hiss.
>>
> I must use  Rich Text Format.

Right - but can you do any post editing of the RTF file to prevent your 
references and directives from being RTF-ed by the editor?


>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
>
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geirm@optonline.net


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Variables and Directives

Posted by Paul Babachanakh <Pa...@uib.cherkassy.net>.
> On Mon, 2003-10-13 at 14:19, Geir Magnusson Jr. wrote:
> > > As a template file I'm using file in Rich Text Format from Microsoft
> > > Word. And when I save it variables and directives may place
> > > separately from sign $ or #. For example like this:
> > >
> > > {\fs18\lang1049\langfe1049\langnp1049  $}{\fs18 dateB}
> > >
> > > Variable dateB and $ place separately.
> > >
> > > The question is: how can I configurate Velocity to replace $ and # to
> > > something else?
> > You can't, but why would you need to?  What is the problem?  (Sorry - I
> > don't get from above what it is...)
>
> I think he's saying that when he saves the file it's inserting
> formatting/RTF-ish info between the $ and variable name.
>
> I think.
Thats right.
>
> Of course, using anything but a plain-text file as a template file is
> probably not a Good Idea, as Word will undoubtedly spew into it and
> change things around. Boo hiss.
>
I must use  Rich Text Format.


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Variables and Directives

Posted by Dave Newton <da...@solaraccess.com>.
On Mon, 2003-10-13 at 14:19, Geir Magnusson Jr. wrote:
> > As a template file I'm using file in Rich Text Format from Microsoft
> > Word. And when I save it variables and directives may place
> > separately from sign $ or #. For example like this:
> >
> > {\fs18\lang1049\langfe1049\langnp1049  $}{\fs18 dateB}
> >
> > Variable dateB and $ place separately.
> >
> > The question is: how can I configurate Velocity to replace $ and # to
> > something else?
> You can't, but why would you need to?  What is the problem?  (Sorry - I 
> don't get from above what it is...)

I think he's saying that when he saves the file it's inserting
formatting/RTF-ish info between the $ and variable name.

I think.

Of course, using anything but a plain-text file as a template file is
probably not a Good Idea, as Word will undoubtedly spew into it and
change things around. Boo hiss.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Variables and Directives

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On Monday, October 13, 2003, at 08:39 AM, Paul Babachanakh wrote:

> Hello all!!!
>
> I have tried to use Velocity Template Engine (version 1.3.1). It's
> wonderful. But I have a problem and I don't understand how to resolve
> it.
>
> As a template file I'm using file in Rich Text Format from Microsoft
> Word. And when I save it variables and directives may place
> separately from sign $ or #. For example like this:
>
> {\fs18\lang1049\langfe1049\langnp1049  $}{\fs18 dateB}
>
> Variable dateB and $ place separately.
>
> The question is: how can I configurate Velocity to replace $ and # to
> something else?
>
> Thank you for your time.

You can't, but why would you need to?  What is the problem?  (Sorry - I 
don't get from above what it is...)

geir

>
> Sincerely,
> Pavel Babachanakh
> paul@uib.cherkassy.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
>
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geirm@optonline.net


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org