සැකිල්ල:Evalx
( )
භාවිතය
[සංස්කරණය]This template evaluates an expression sequence using Module:Wikilisp. Pass the expression sequence as the first unnamed template parameter; all parameters to the template are also passed to the the module. For example,
{{evalx|(get-substring (get-arg 2) 2 3)|abcd}}
would expand to
- bc
Here's a nontrivial example, made to work in concert with dialog verb edit. It modifies the entire content of a wiki page (provided through template parameter SUBJECT-CONTENT
) to submit the article for review on Wikinews, by removing calls to templates {{develop}} and {{tasks}} and adding a call at the top of the page to template {{review}}.
{{evalx|(define s (get-arg 2)) (define t (filter (parse s) call? (\x (member? (ucfirst (trim (get-substring s (nth (get-parts x) 1)))) (list "Dialog/submit" "Develop" "Developing" "Development" "Draft" "Tasks"))))) (set-substring s (+ (list (list 1 0)) t) (+ (list "{{(*}}{{(*}}review{{*)}}{{*)}}") (map (\x "") t))) |{{{SUBJECT-CONTENT|}}}}}A different module, to use instead of Module:Wikilisp, may be specified by non-blank template parameter
test-eval
.
අභ්යන්තර ක්රියාකාරීත්වය
[සංස්කරණය]When Module:Wikilisp is #invoke
d directly, rather than through an intermediary template such as {{evalx}}, the module point of entry is Lua function rep
, and the invocation parameters are accessible through Wikilisp functions get-arg
and get-arg-expr
. However, the intermediary template cannot explicitly pass its arbitrary template parameters to the invocation since it doesn't know their names in advance. To compensate, an alternative point of entry is provided through Lua function trep
, that feeds get-arg
and get-arg-expr
the parameters to the intermediary template instead of the parameters to #invoke
.
ආශ්රිත
[සංස්කරණය]- Module:Wikilisp for documentation of the expression language.