You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Nathan Bubna <nb...@gmail.com> on 2008/05/01 18:39:20 UTC

Re: creating macro

what template are you calling the macro from?  does weblog.vm both define
and call the macro?  if so, then your velocity configuration is such that
"inline" macros are disabled.

if you are calling the macro from separate template, then you need to
register weblog.vm as a velocimacro.library.

On Tue, Apr 29, 2008 at 11:47 PM, deligeli <od...@jpost.com> wrote:

>
> Hi,
> I am trying to define a new macro.
> I defined in weblog.vm, sitting in the library: \WEB-INF\velocity of the
> webapplication.
> #macro (showStringShort $string $size)
>   $string.substring(0,$size)
> #end
>
> I call it from the template,like this:
> #showStringShort("hello" 3)
>
> But it displays:
> #showStringShort("hello" 3)
> As if the macro doesn't exist.
> What did I miss?
>
> Odelya
> --
> View this message in context:
> http://www.nabble.com/creating-macro-tp16976702p16976702.html
> Sent from the Velocity - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

Re: creating macro

Posted by Nathan Bubna <nb...@gmail.com>.
This is described in the "Velocimacro" section of this page:

http://velocity.apache.org/engine/releases/velocity-1.5/developer-guide.html#velocity_configuration_keys_and_values

On Sun, May 4, 2008 at 12:18 AM, deligeli <od...@jpost.com> wrote:
>
>  How do I register it as velocimacro.library?
>
>
>
>  Nathan Bubna wrote:
>  >
>  > what template are you calling the macro from?  does weblog.vm both define
>  > and call the macro?  if so, then your velocity configuration is such that
>  > "inline" macros are disabled.
>  >
>  > if you are calling the macro from separate template, then you need to
>  > register weblog.vm as a velocimacro.library.
>  >
>  > On Tue, Apr 29, 2008 at 11:47 PM, deligeli <od...@jpost.com> wrote:
>  >
>  >>
>  >> Hi,
>  >> I am trying to define a new macro.
>  >> I defined in weblog.vm, sitting in the library: \WEB-INF\velocity of the
>  >> webapplication.
>  >> #macro (showStringShort $string $size)
>  >>   $string.substring(0,$size)
>  >> #end
>  >>
>  >> I call it from the template,like this:
>  >> #showStringShort("hello" 3)
>  >>
>  >> But it displays:
>  >> #showStringShort("hello" 3)
>  >> As if the macro doesn't exist.
>  >> What did I miss?
>  >>
>  >> Odelya
>  >> --
>  >> View this message in context:
>  >> http://www.nabble.com/creating-macro-tp16976702p16976702.html
>  >> Sent from the Velocity - User mailing list archive at Nabble.com.
>  >>
>  >>
>  >> ---------------------------------------------------------------------
>  >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>  >> For additional commands, e-mail: user-help@velocity.apache.org
>  >>
>  >>
>  >
>  >
>
>  --
>  View this message in context: http://www.nabble.com/creating-macro-tp16976702p17043510.html
>
>
> Sent from the Velocity - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>  For additional commands, e-mail: user-help@velocity.apache.org
>
>

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


Re: creating macro

Posted by deligeli <od...@jpost.com>.
How do I register it as velocimacro.library?

Nathan Bubna wrote:
> 
> what template are you calling the macro from?  does weblog.vm both define
> and call the macro?  if so, then your velocity configuration is such that
> "inline" macros are disabled.
> 
> if you are calling the macro from separate template, then you need to
> register weblog.vm as a velocimacro.library.
> 
> On Tue, Apr 29, 2008 at 11:47 PM, deligeli <od...@jpost.com> wrote:
> 
>>
>> Hi,
>> I am trying to define a new macro.
>> I defined in weblog.vm, sitting in the library: \WEB-INF\velocity of the
>> webapplication.
>> #macro (showStringShort $string $size)
>>   $string.substring(0,$size)
>> #end
>>
>> I call it from the template,like this:
>> #showStringShort("hello" 3)
>>
>> But it displays:
>> #showStringShort("hello" 3)
>> As if the macro doesn't exist.
>> What did I miss?
>>
>> Odelya
>> --
>> View this message in context:
>> http://www.nabble.com/creating-macro-tp16976702p16976702.html
>> Sent from the Velocity - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/creating-macro-tp16976702p17043510.html
Sent from the Velocity - User mailing list archive at Nabble.com.


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