Foros de discusión

Using #js() in velocity template

Paul Franky, modificado hace 14 años.

Using #js() in velocity template

New Member Mensajes: 8 Fecha de incorporación: 11/12/09 Mensajes recientes
Hi!

We're using following code inside our custom velocity template:

#js("$javascript_folder/my-javascript.js")


The resulting html code works just fine except its empty id attribute:

<script id="" src="/our-theme/javascript/my-javascript.js" type="text/javascript"></script>


Is it required by Liferay? How should we set it? Could we delete it?
Doe Del, modificado hace 12 años.

RE: Using #js() in velocity template

New Member Mensaje: 1 Fecha de incorporación: 2/03/12 Mensajes recientes
Hi Paul,

I just ran into the same issue.

As far as I can tell, the LR-guys created a macro called "#js()" in the velocity file "VM_liferay.vm".

There is another macro for css files as well.

This macro is used internally by liferay and set's the script's ID to "mainLiferayThemeJavaScript" if the filename is "$js_main_file" and leaves it empty otherwise.

But: You are not forced to use this macro, you can do what the macro does by writing:

<script id="foo" src="/path/to/bar.js" type="text/javascript" />

instead of:

#js("/path/to/bar.js")