Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-705

Dynamic VTL reference modification directive

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Engine
    • None

    Description

      Currently EventHandlers are defined in velocity.properties like:

      eventhandler.referenceinsertion.class =

      The problem is that AFAIK this handler is active in every reference evaluation (and every template). I propose a dynamic setting that can be chained and turned on and off during template rendering.

      Syntax might be something like:

      #filter($myReferenceModifier)

      any VTL here ($foo type references are modified using the class referred by $myReferenceModifier)
      #end

      The basic idea is that you put some classes that implement e.g. ReferenceInsertionEventHandler interface to the Context and then you can use those to filter/modify some selected parts of the template. #filter directive should allow nesting (one #filter directive contain another #filter directive).

      It's probably also necessary to disable filtering for selected elements inside the filter block.

      It might be also useful to be able to limit the amount of reference names that are passed to the filter. Like:
      #filter($myReferenceModifier ['a', 'foo', 'html'])


      Use Case for this feature is that often you need to escape form values and other elements to avoid XSS attacks etc. Escaping all references in all templates seems like an overkill (and isn't very performance friendly either). This feature would allow you to do escaping dynamically only for selected elements.

      What do you think?

      Attachments

        Activity

          People

            Unassigned Unassigned
            wyla Jarkko Viinamäki
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: