Accessing processed HTML from processors

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing processed HTML from processors

Zemi
Administrator
Let's suppose we have the following template code:
      < span th:text="${user.name}" >Name< /span >
which results in the following HTML code:
      < span >Peter< /span >.

I can access the template code via the "element" parameter of "process" method.

Is it possible to access the processed HTML code from an attribute processor?

For example:
     <div my:example="true">
          ...
          < span th:text="${user.name}" >Name< /span >
          ...
     </div>

Is it possible for my:example attribute processor get the '< span >Peter< /span >' HTML code and post-process it?
Reply | Threaded
Open this post in threaded view
|

Re: Accessing processed HTML from processors

Zemi
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: Accessing processed HTML from processors

danielfernandez
Administrator
In reply to this post by Zemi
Zemi wrote
For example:
     <div my:example="true">
          ...
          < span th:text="${user.name}" >Name< /span >
          ...
     </div>

Is it possible for my:example attribute processor get the '< span >Peter< /span >' HTML code and post-process it?
Hi,

You cannot access the result of your th:text="${user.name}" that way because the "my:example" attribute will execute before the th:text (nodes are executed in in-order).

Nevertheless, you could add a my:example attribute to the same tag as your th:text with a higher precedence value, and in that case you would be able to access from my:example the results of th:text:

< span th:text="${user.name}" my:example="true" >Name< /span >

Attribute execution precedence (defined in the IAttrProcessor interface) allows you to specify the order in which attributes in the same tag will be executed. Just set your my:example attribute processor to a value higher than th:text and you will be able to see the results of the th:text attribute.

Regards,
Daniel