NetTalk Central

Author Topic: Method to substitute <!-- Net:s:SessionVariable --> in HTML?  (Read 7475 times)

JohanR

  • Sr. Member
  • ****
  • Posts: 436
    • View Profile
    • Email
Method to substitute <!-- Net:s:SessionVariable --> in HTML?
« on: November 07, 2026, 06:03:15 AM »
Hi,

I have some HTML loaded in a session variable.
the HTML contains a tag <!-- Net:s:SessionVariable -->

Is there a method that will parse/substitute the tags?

thanks

Johan


osquiabro

  • Hero Member
  • *****
  • Posts: 728
    • View Profile
    • Email
Re: Method to substitute <!-- Net:s:SessionVariable --> in HTML?
« Reply #1 on: November 07, 2026, 06:33:14 AM »
yes you can with string Theory, example of my code

 Htm:TemplateId = 3
        GET(HtmlTemplates,Htm:PK_HtmlTemplates)
        IF ~ERROR()
            Loc:HTML = Htm:TemplateHTML
            st.SetValue(Loc:HTML)         
            st.replace('@nombre@',p_web.GSV('nombre'))
            st.replace('@fechadepago@',format(p_web.GSV('Afi:FechaPago_DATE'),@d03))
            st.replace('@cantidadpagada@',FORMAT(p_web.GSV('Afi:CantidadPagada'),@n$6.2))
            st.replace('@referencia@',p_web.GSV('Afi:NumeroPago' ))
            st.replace('@recibo@',p_web.gsv('Afi:NumeroPago'))
            Loc:HTML = st.Getvalue()       
            Loc:TemplateSubject = Htm:TemplateSubject
            st.SetValue(Loc:TemplateSubject)               
            Loc:TemplateSubject = st.Getvalue()
        END
        Access:HtmlTemplates.Close()       

JohanR

  • Sr. Member
  • ****
  • Posts: 436
    • View Profile
    • Email
Re: Method to substitute <!-- Net:s:SessionVariable --> in HTML?
« Reply #2 on: November 07, 2026, 09:52:16 PM »
Hi,

Yes, thanks, I can certainly do manual replace exercise.
Was wondering if there was a handy NT function that does the same as the tag replacement with the static files.
Using the NT functions would be preferable as it would work for all cases and follow the NTWS method of doing it.

thanks

Johan

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11344
    • View Profile
Re: Method to substitute <!-- Net:s:SessionVariable --> in HTML?
« Reply #3 on: November 17, 2026, 03:21:06 PM »
typically it's done for you. But it depends on the context. So tell us more about what HTML you are using here?

JohanR

  • Sr. Member
  • ****
  • Posts: 436
    • View Profile
    • Email
Re: Method to substitute <!-- Net:s:SessionVariable --> in HTML?
« Reply #4 on: November 19, 2026, 03:04:24 AM »
Hi Bruce

I have a form with a display field, this contains an HTML snippet, and the HTML also has some dynamic data from variables.
Currently I have the snippet in a file on disk and the display field source is a file tag.
The dynamic data is updated when the field is refreshed.

However if the HTML is pre-loaded in a session variable the dynamic data is not updated if the field is refreshed.

I have tried to follow the difference in code between the file tag and session variable, but not sure of the code that triggers the replacing of the tags eg. <!-- Net:s:cli:email -->

In the past I have used a procedure to generate HTML and then did the replacing by hand, so it's do-able.
As there are other tags available, like host besides session.

Would just be handy if the builtin methods can be used or triggered.

a simple example

<dl class="rows">
      <div class="row">
       <dt>
        Full name
       </dt>
       <dd data-value="fullName">
        <!-- Net:s:cli:first_name --><!-- Net:s:cli:name -->
       </dd>
      </div>
      <div class="row">
       <dt>
        Email
       </dt>
       <dd data-value="email">
        <!-- Net:s:cli:email -->
       </dd>
      </div>
      <div class="row">
       <dt>
        Mobile
       </dt>
       <dd data-value="mobile">
        <!-- Net:s:cli:cell_nr -->
       </dd>
      </div>
</dl>


thanks

Johan