Render an unknown type (x-tmpl) in Thymeleaf 3

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

Render an unknown type (x-tmpl) in Thymeleaf 3

bphilipnyc
I am using an external library called BlueImp and I want to have it render on a Thymeleaf 3 template.  It seems they use a proprietary "x-tmpl" dialect that looks somewhat like JSP scriptlets.  

How would I have Thymeleaf render this?  I am thinking something like a th:inline="raw" is what I would need but that doesn't exist.  It works fine on JSP.

    <!-- The template to display files available for upload -->
    <script id="template-upload" type="text/x-tmpl">
            {% for (var i=0, file; file=o.files[i]; i++) { %}
                <tr class="template-upload fade">
                    <td>
                        <span class="preview"></span>
                    </td>
                    <td>
                        <p class="name">{%=file.name%}</p>
                        <strong class="color--error field--error"></strong>
                    </td>
                    <td>
                        <p class="size">Processing...</p>
                        <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-success" style="width:0%;"></div></div>
                    </td>
                    <td>
                        {% if (!i && !o.options.autoUpload) { %}
                            <button type="submit" class="btn btn--success btn--lg start" id="uploadStub" name="_eventId_uploadStub" style="padding: 2px;">
                                <span class="btn__text type--uppercase">
                                    Start
                                </span>
                            </button>
                        {% } %}
                        {% if (!i) { %}
                            <button class="btn btn--warning btn--lg type--uppercase cancel">
                                <span class="btn__text">
                                    Cancel
                                </span>
                            </button>
                        {% } %}
                    </td>
                </tr>
            {% } %}
    </script>


This external link showcases the problem too.  The solution was to partially go with Velocity in the end:

https://nixmash.com/post/spring-mvc-thymeleaf-and-the-blueimp-fileupload-plugin

Reply | Threaded
Open this post in threaded view
|

Re: Render an unknown type (x-tmpl) in Thymeleaf 3

bphilipnyc
We were able to solve this - there were some missing CSS classes and incorrect jQuery logic that prevented the x-tmpl from displaying correctly.