|
|
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Skylark functions/links
Skylark functions/links [message #42922] |
Mon, 14 April 2014 17:46 |
mingodad
Messages: 53 Registered: February 2008 Location: Spain
|
Member |
|
|
Hello !
I need to have a way to url_encode some values in witz templates (not in c++), it seems that there is a way to define new functions to be available in witz templates but is not documented, I looked at the source code but could not see how to do it.
Someone can shed a light here ?
Also the way to make links is not too good, I needed to add bookmarks to the links but the actual link function do not seem to accept it and also return a quoted string what makes add things to it in witz impossible.
I replaced on souce all ("\"" + theLink + "\"") by just (theLink) and could achieve my needs.
Another topic related with witz is the actual way to add witz code prefixing with "#$" works fine for hand write code from programmers but it's not friendly to designers and wysiwyg tools (need be aware of escaping "#$" and it can makes invalid html).
I propose to put then hidden inside tags:
<if()><else/></endif> <for()></endfor> ${variable}
It's a bit anoying for hand write but for wysiwyg editors it's fine.
Cheers !
|
|
|
|
Re: Skylark functions/links [message #42925 is a reply to message #42924] |
Mon, 14 April 2014 18:49 |
mingodad
Messages: 53 Registered: February 2008 Location: Spain
|
Member |
|
|
Thanks for the link !
I've created this function:
Value WitzUrlEncode(const Vector<Value>& arg, const Renderer *) {
if(arg.GetCount() != 1 || !IsString(arg[0]))
return String();
StringBuffer buf;
UrlEncode(buf, String(arg[0]));
return Value(buf.Begin());
}
INITBLOCK {
Compiler::Register("url_encode", WitzUrlEncode);
}
But I get two kind of errors ($rec.name has valid content) :
------
$url_encode($rec.name) >>> Internal server error (206,12): missing number
------
or
------
$url_encode(rec.name) >>> *************PANIC: Invalid memory access! Segmentation fault (core dumped)
------
Probably a bug in U++ !!!
Attached sample to test!
[Updated on: Mon, 14 April 2014 19:12] Report message to a moderator
|
|
|
Re: Skylark functions/links [message #42926 is a reply to message #42925] |
Mon, 14 April 2014 20:16 |
|
mirek
Messages: 14162 Registered: November 2005
|
Ultimate Member |
|
|
mingodad wrote on Mon, 14 April 2014 16:49Thanks for the link !
I've created this function:
Value WitzUrlEncode(const Vector<Value>& arg, const Renderer *) {
if(arg.GetCount() != 1 || !IsString(arg[0]))
return String();
StringBuffer buf;
UrlEncode(buf, String(arg[0]));
return Value(buf.Begin());
}
INITBLOCK {
Compiler::Register("url_encode", WitzUrlEncode);
}
But I get two kind of errors ($rec.name has valid content) :
------
$url_encode($rec.name) >>> Internal server error (206,12): missing number
------
or
------
$url_encode(rec.name) >>> *************PANIC: Invalid memory access! Segmentation fault (core dumped)
------
Probably a bug in U++ !!!
Attached sample to test!
Well, this is nice one...
What happened here is that you have probably seen
UrlEncode(StringBuffer& b, const char *s) signature in Skylark - but that is local function (my fault, should have made it static).
What got called instead was
UrlEncode(const char *begin, const char *end);
(from Core/Inet.h)
which, having begin and end pointing to unrelated things, obviously crashed.
This works:
Value WitzUrlEncode(const Vector<Value>& arg, const Renderer *) {
return arg.GetCount() == 1 && IsString(arg[0]) ? UrlEncode(arg[0]) : String();
}
INITBLOCK {
Compiler::Register("url_encode", WitzUrlEncode);
}
|
|
|
|
|
Goto Forum:
Current Time: Fri Dec 13 23:29:28 CET 2024
Total time taken to generate the page: 0.02852 seconds
|
|
|