How to convert this for velocity template?

感情迁移 提交于 2019-12-13 07:27:40

问题


I have html content. I want to convert it to velocity template. Please provide the steps to be taken to convert it to template.

I need to insert the html in database also.

Following is the html :

<div class="divNumberFilter">
    <div class="divLabel" style="width: 70px;">Number:</div>
    <div class="divInputField">
        <input id="$tags.searchStandard" type="text" style="width: 100px;">
        <script src='<s:url value=""></s:url>' type="text/javascript"></script>
        <script type="text/javascript" charset="utf-8">
            addOnload(grouping());
            addOnload(initilizeStandardAutoComplete());
        </script>
    </div>
    <div class="clear"></div>
</div>

<!-- Standard Description filter -->
<div class="divDescriptionFilter">
    <div class="divLabel" style="width: 70px;">Description:</div>
    <div class="divInputField">
        <input id="$tags.standardFilter" type="text" style="width: 318px;">
        <script src='<s:url value=""></s:url>' type="text/javascript"></script>
        <script type="text/javascript" charset="utf-8">
            addOnload(grouping());
            addOnload(initilizeStandardDescAutoComplete());
        </script>
    </div>
    <div class="clear"></div>
</div>
<div id="standard_list" class="selection_property_div" style="padding-bottom: 5px;">
</div>

Please help..


回答1:


Okay first of all, to convert this into a Velocity template, you must have an idea what you EXACTLY want to do. That's step 1.

Then start writing the code in a velocity template file. Figure out what part would be dynamic, i.e., would be rendered by the Velocity Template Engine., which I guess you already know.

<input id="$tags.standardFilter" type="text" style="width: 318px;">

Inserting it into database.

You would need a table structure like this.

create table if not exists Templates (
    template_file_name varchar(50), --The column to store the name of templates.
    html mediumblob, --The column which actually has the velocity templates.
    lastmod timestamp --The column which contains the last modification information.
);

Then use the DataSourceResourceLoader and configure it (please read Velocity Docs for reference).

Make a VelocityEngine out of the configurations of the DataSourceResourceLoader.

have FUN.

--Cheers, Jay.



来源:https://stackoverflow.com/questions/33916877/how-to-convert-this-for-velocity-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!