Hi Tony,
I'll try your solution, it gives me control what a template is allowed to do.
Thank you,
Stefan
| Poster | Content |
|---|---|
|
nk4um User
Posts: 33
|
Hi Tony, I'll try your solution, it gives me control what a template is allowed to do. Thank you, Stefan |
|
nk4um Moderator
Posts: 485
|
Hi Stefan, if all you're after is a change in syntax of the source TRL template then I wouldn't suggest constructing spaces to create aliases for the passed arguments. There is much more elegant, in my eyes, way to achieve what you want. I would create a transform accessor that takes your alternate form of TRL template, let me call it STRL (Stefans Text Recursion Language) ;-) and transforms it to plain old TRL. It's easy to do this with regular expressions. Then we would give this transform a grammar. A simple way to do it would be an active grammar like: active:STRLtoTRL+operand@res:/myTemplate.strl then when you call TRL you call TRL with a template of this identifier rather than just "res:/myTemplate.strl". There are many options, in terms of grammars to make this more concise though. Cheers, Tony |
|
nk4um User
Posts: 33
|
Hello Tony, I want to do the following:
I want to use one endpoint per template, that collects the data, calls TRL/XRL with the appropriate template as as argument and returns the resolved template. To push the data into the template I could try to
Thank you, Stefan |
|
nk4um Moderator
Posts: 485
|
Hi Stefan, if you SOURCE "title" then you are going to be looking to resolve an identifier with the identifier "title". When arguments are added to requests they are put into a pass-by-value space with an identifier "arg:title" so that is how they must be sourced. I.e. you must use ${arg:title} in TRL. Now it is possible to create your space, add resources with an idenfier of title to it and then inject it into the request scope of an issued request. Then you could resolve a resource with an identifier of "title". But is that what you really want? Cheers, Tony |
|
nk4um User
Posts: 33
|
Hello, I do have a problem in understanding the the pass-by-value construct. The documentation says: When invoking functions and other services that might require arguments it is often necessary to pass a specific value or literal representation. [...] Each specific value or literal representation should then be given a unique identifier and placed into the dynamic space. The unique identifier for representation should then be specified as the appropriate argument in the identifier of the function evaluation request. [...] Examples: NetKernel Foundation API: INKFRequest.addArgumentByValue() Literal layout I tried the following with TRL and a template that requests
req = context.createRquest("active:trl");
req.addArgument(template, "res:/something.xml");
req.addArgumentByValue("title", "The Title");
req.addArgumentByValue("content", "The Content");
context.issueRequest(req);
The result is an exception because of a failure to resolve 'SOURCE title'. In the scope of the resolution as shown by the exception there is a space '(pbv(title, content))'. Why does the resolution fail? The objective is to use TRL in the described way without having to write something like Thank you, Stefan |