Last active
May 2, 2017 06:15
-
-
Save jolle-c/d72c8af689cb7e79ccc1 to your computer and use it in GitHub Desktop.
Revisions
-
jolle-c revised this gist
May 2, 2017 . 1 changed file with 21 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,12 +4,33 @@ wrp Quick way to grap a web_request param 2017-05-02 JC Added examples 2014-10-08 JC Added to Gist 2014-10-08 JC Added separate methods for queryparams and postparams 2014-08-24 JC Rewrite of the wrp method once again. This time with code suggested by Brad Lindsay in a lassotalk thread. Introduces the param -all 2014-08-22 JC Complete rewrite to produce leaner and more reliable code. Arrays are now returned as staticarrays 2013-12-08 JC adjusted to only initiate once 2013-12-07 JC First version EXAMPLES local( checkboxinput = wrp('checkboxinput', -all), myinput = wrp('myinput') ) #checkboxinput -> type // staticarray #myinput -> type // string or void depending on if it has content or not // this will only find GET parameters local( myqueryparam = wrpq('myqueryparam') ) // this will only find POST parameters local( mypostparam = wrpp('mypostparam') ) */ define wrps => var(__wrp) -> isa(::staticarray) ? $__wrp | -
jolle-c renamed this gist
Oct 8, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jolle-c created this gist
Oct 8, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,71 @@ [ /**! wrp Quick way to grap a web_request param 2014-10-08 JC Added to Gist 2014-10-08 JC Added separate methods for queryparams and postparams 2014-08-24 JC Rewrite of the wrp method once again. This time with code suggested by Brad Lindsay in a lassotalk thread. Introduces the param -all 2014-08-22 JC Complete rewrite to produce leaner and more reliable code. Arrays are now returned as staticarrays 2013-12-08 JC adjusted to only initiate once 2013-12-07 JC First version */ define wrps => var(__wrp) -> isa(::staticarray) ? $__wrp | $__wrp := (with p in web_request -> params let name = #p -> first -> asstring let value = #p -> second -> asstring select pair(#name = #value)) -> asstaticarray define wrp(name::string = string, -all::boolean = false) => { local(wrp) = wrps -> find(#name) if(#all) => { return (with param in #wrp select #param -> second) -> asstaticarray } #wrp -> isempty ? return void return #wrp -> get(1) -> second } define wrpqs => var(__wrpq) -> isa(::staticarray) ? $__wrpq | $__wrpq := (with p in web_request -> queryparams let name = #p -> first -> asstring let value = #p -> second -> asstring select pair(#name = #value)) -> asstaticarray define wrpq(name::string = string, -all::boolean = false) => { local(wrp) = wrpqs -> find(#name) if(#all) => { return (with param in #wrp select #param -> second) -> asstaticarray } #wrp -> isempty ? return void return #wrp -> get(1) -> second } define wrpps => var(__wrpp) -> isa(::staticarray) ? $__wrpp | $__wrpp := (with p in web_request -> postparams let name = #p -> first -> asstring let value = #p -> second -> asstring select pair(#name = #value)) -> asstaticarray define wrpp(name::string = string, -all::boolean = false) => { local(wrp) = wrpps -> find(#name) if(#all) => { return (with param in #wrp select #param -> second) -> asstaticarray } #wrp -> isempty ? return void return #wrp -> get(1) -> second } ]