TOPIC: InvertHtml and Eval() ... how to pass arguments?
#1584
InvertHtml and Eval() ... how to pass arguments? 10 Months, 2 Weeks ago
How can I pass an argument to Eval() of an InvertHtml? For instance:

HelloHTML:
Code:


'<html><body><h1>Hello, <$= name $></h1></body></html>'



DoHelloHTML:
Code:


s = InvertHtml(HelloHTML)
Print(s.Eval(name: 'John'))



Is there any way to inject a value into it?

Jeremy
 
 
#1585
Re:InvertHtml and Eval() ... how to pass arguments? 10 Months, 2 Weeks ago
BTW. I was hoping for a non-Global type solution. i.e. not Sundeido.name = 'John' then <$= Suneido.name $>.

Jeremy
 
 
#1587
Re:InvertHtml and Eval() ... how to pass arguments? 10 Months, 2 Weeks ago
The code that it returns is not a complete function, so you can just wrap it in function and pass values as arguments:

Code:

s = "function (name) {n" $ InvertHtml(...) $ "}"
f = s.Compile()
html = f("Jeremy")


If you need a bunch of values you can pass an object and reference members of the object (e.g. pass x and reference x.name)

The above is the method I would suggest, but you could just add assignments:

Code:

n = "George"
s = "name = " $ Display(n) $ "n" $ InvertHtml(...)
html = s.Eval()

 
 
andrew