B4J Code Snippet [web]Velocity Template Language (VTL)

aeric

Expert
Licensed User
Longtime User
@aeric Using your method where do I put the template file? it can't find it wherever I put it lol.
I thought you are feeling adventurous. Why so fast defeated by your Diablo monsters? ?
Sometimes you need some luck and I have given you hint in my screen.
If you have noticed, I use File.DirInternal in B4A. Copy the file from assets to DirInternal. You need the exact path where I use File.Combine to load the file.

Here is the demo for B4J and B4A.
 

Attachments

  • WebviewVTL.zip
    16.5 KB · Views: 152

Daestrum

Expert
Licensed User
Longtime User
Was having too much fun to play Diablo

Just working on using strings for the templates, so they can be dynamically created at run time.
 

Daestrum

Expert
Licensed User
Longtime User
Did you try that VelocityLib as a library? saves having all those #additionalJar lines.
 

Daestrum

Expert
Licensed User
Longtime User
Calling subs in your app is quite easy

1, pass a reference to the template
2, call the sub from the template

B4X:
in app

vtl.putContext("caller",Me)

' the sub we want to call from the template
Sub justATest( S As String)
      log(S)
End Sub

in template

$caller._justatest("Hello")
 

aeric

Expert
Licensed User
Longtime User
I tried once and having an error. Will try again later.
I create a new thread for the libraries

 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…