You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Thomas Bernhard <tb...@yahoo.com> on 2007/11/12 17:39:53 UTC

How to include only a part of a file?

How to include only a part of a file into another one with Velocity and this
to be done in the template (so not from Java code).

With FreeMarker  I would do the following:
----
<pre>
          <template:include src="../mypages/items.html"
                        elements="/html/body/*[@class='aItem' and
position()<=8]"/>
</pre>
----

How to achieve the above in a Velocity template?
With the #include macro syntax seems to allow the inclusion of an entire
file only :(.

Thanx,
Tom.
-- 
View this message in context: http://www.nabble.com/How-to-include-only-a-part-of-a-file--tf4792246.html#a13709026
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: How to include only a part of a file?

Posted by Nathan Bubna <nb...@gmail.com>.
On Nov 12, 2007 8:39 AM, Thomas Bernhard <tb...@yahoo.com> wrote:
>
> How to include only a part of a file into another one with Velocity and this
> to be done in the template (so not from Java code).
>
> With FreeMarker  I would do the following:
> ----
> <pre>
>           <template:include src="../mypages/items.html"
>                         elements="/html/body/*[@class='aItem' and
> position()<=8]"/>
> </pre>
> ----
>
> How to achieve the above in a Velocity template?
> With the #include macro syntax seems to allow the inclusion of an entire
> file only :(.

correct.  if you want to be able to do this, you'll either need to
create your own subclass of the Include directive or create a "tool"
class with a method you can call to do this.

> Thanx,
> Tom.
> --
> View this message in context: http://www.nabble.com/How-to-include-only-a-part-of-a-file--tf4792246.html#a13709026
> 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