Calling UI Macros - <g:macro_name /> or <g2:macro_name /> ?

Makosko
Tera Expert

Hello Gurus,

I`ve created custom macros, which I want to initiate/call from within other macros or UI pages. However, one thing I am not sure about is "the phase" in which a nested macro should be initiated.. Should i be using <g or <g2 instead ? What is the best/recommended practice on this ?

thanks a lot for your help

Cheers

1 ACCEPTED SOLUTION

Here goes the examples that probes the statement on the prior post:




Given a simple macro like the following:




<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


  <g:evaluate var='jvar_now'>


  gs.nowNoTZ();


  </g:evaluate>



  This macro current Date is: <input id="id_test" value='${jvar_now}' />



</j:jelly>



1 - In a form: The results are cached when used from a form. I reloaded the below form multiple times and the time displayed never changed.


MacroIsCachedInForm.gif



2- In a UI Page: The results are NOT cached when used in a UI page. The time will change every time i reloaded a UI page from which I'm invoking the macro:



MacroNotCachedFromUIPage.gif



3- In a MOBILE view: The results are NOT cached. The time will change every time I reloaded the macro using the view path for mobile


MacroNotCachedInMobile.gif



So, having reviewed our examples, you should only use g1 when your results can be cached and been aware that these would not be cached if used from a UI Page or from a Mobile View.



I really hope this was helpful. I enjoyed building the example on the various views... so thanks for asking the follow up question!



Thanks,


Berny


View solution in original post

13 REPLIES 13

Deepak Ingale1
Mega Sage

Did you manage to call custom UI macro from g tag?


I am struggling to do this.


I also request community members also to help on this if anyone knows how to call custom UI macro in UI page using g tag.


Here is an example of how I've done it (i.e. calling a UI Macro from within a UI Page or from within another UI Macro):



<g:call function="my_ui_macro"   my_parm_one='parm1 value'   my_parm_two='parm2 value' />



Ty


Thijs Daemen
Mega Guru

Hi Maros,



There is a really good blog by SlightlyLoony out on the community about this, maybe that will help you to get an answer.



Jelly: A Tale of Two Phases...


Jelly: The Second Phase of Madness...


I believe I`ve read these articles. Most of it is very obvious. However if you look at SNOW jelly code, you`ll find some confusing parts. Running phase 2 snippets to determine whether or not to execute phase 1 code.. which is a bit weird as you would expect that to run first...