-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.lasso
422 lines (284 loc) · 7.75 KB
/
example.lasso
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>L-Debug - Example</title></head><body bgcolor="#ebead5"><?LassoScript// Content type fixdefine content_type => content_header >> 'Content-Type' ? content_header->find('Content-Type')->first->value // Define Type(s)if(integer(client_getParam('reload')) == 1); include('debug.type.lasso') debug sleep(500) redirect_url('example.lasso')else '<a href="example.lasso?reload=1">reload</a>'/if//debug->injectJS;//define h_test(p::string,-header::boolean=false) => 'OK'//h_test('header',-header=true)//debug->activate('console');debug->activate();//============================================================================//// -> Basic Examples////............................................................................ // A header debug('Basic Examples',-header) // Plain text debug('hello world') // An array debug(array('Monday','Tuesday','Wednesday')) // Slightly more complex types local('map' = map) #map->insert('item1'=array('one','two','three','four'='isPair')); #map->insert('item2'=array('a','b','c')); #map->insert('item3'=map('x'='y')); debug(#map)//============================================================================//// -> Custom Labels////............................................................................ local('myArray' = array('one','two','three')) debug('myArray label' = #myArray) debug->timer('Basics')//============================================================================//// -> Blocks////............................................................................ debug->header('Blocks') debug->open('Custom block: .method()') debug('text A'); debug('text B'); debug(array(123,123,123='ABC')); debug(array(123,123,123=array('another','nested','array'))); debug('text C'); debug->open('Nested block: .anotherMethod()'); debug('text D'); debug('text F'); debug->close; debug->close; /* // Activate L-Debug; debug->activate( -js = 'debug.js', -css = 'debug.css', -mode = (client_getParams >> 'mode' ? client_getParams->find('mode')->first->second) );*///============================================================================//// -> Custom Types////............................................................................ /* Currently disabled debug->myThing('Some text'); debug->customThing(-open); debug('MyBlock'); debug('My' = array(123,12111,12314)); debug->close;*/ // Hidden timer debug->timer('Custom Types'); //============================================================================//// -> Custom Tag support////............................................................................ debug('Custom Tags',-header) define cleanString(what::string)=>{ debug->open(method_name,params) handle => {debug->close} // protect => { return( #what->join(' ')) // } } protect => {cleanString('this will break')} define captureTest(...)=>{ debug->open({}) handle => debug->close } captureTest('what','this will break',-this='that') define blockTest(...)=>{ debug => { debug('this is wrapped') } } blocktest('23')//============================================================================//// -> Block Timers////............................................................................ debug('Timed Block')=>{ debug('Done Something'); sleep(30) } // Hidden timer debug->timer('Timed Block'); //============================================================================//// -> Line timers////............................................................................ debug('Slow Examples') sleep(3) debug->time('Slow Example') sleep(5) debug->time('Really Slow Example') //============================================================================//// -> Daisy Chaining////............................................................................ debug->open('client_getParams')->this(client_getParams)->close; debug->open('client_postParams')->this(client_postParams)->close; local('trace') = array; #trace->insert('Test one'); #trace->insert('Test two'); #trace->insert('Test three'); #trace->insert('Test four and five'); debug->open('#trace')->close(#trace);//============================================================================//// -> Hidden Timers////............................................................................ debug->timer('Timer A'); sleep(4) debug->timer('Timer B'); sleep(8) debug->timer('Timer C'); sleep(16) debug->timer('Timer D');//============================================================================//// -> Tracking Sub Routines////............................................................................ define mytask(task::string=string) => { debug => { match(#task) => { case('delete') sleep(50) debug('Deleting Record - '+error_msg) case('loop') debug('Looping') loop(5)=>{ debug(loop_count = 'Loop - '+error_msg) } } } } myTask('delete'); myTask('loop'); // Hidden timer debug->timer('My Task'); //============================================================================//// -> Custom Types////............................................................................ define_type('myType') define_tag('onCreate') debug => { self->init; } /define_tag; define_tag('init') debug => { debug('Initialised'); } /define_tag; define_tag('tagThatBreaks'); debug => { strng('I don\'t work'); } /define_tag; /define_type; local('myType') = myType; protect; #myType->tagThatBreaks; /protect; // Hidden timer debug->timer('Custom Types'); //============================================================================//// -> SQL Support////............................................................................ debug->header('SQL Support'); // sleep(20)// debug->error('test error'); protect => { debug('SQL search') => { local('sql') = '# My Statement SELECT * FROM myMissing.table'; debug->sql(#sql) inline( -database = 'myDb', -table = 'myMissingTable', -sql = #sql ) => { } } } debug('done',-timer) //============================================================================//// -> Code Rendering Examples////............................................................................ debug->header('Code Rendering'); debug->sql('/* SQL Statements */ SELECT * FROM mytable WHERE test LIKE "this%"'); debug->js('//Javascript function test(param){ alert(\'Hello World\'); }');debug->css('/* CSS */ div.debug{ width(554px) margin(20px auto 20px auto) font-size(11px) background(#fff) clear(both) padding(8px) border( 1px solid #CCC) overflow(hidden) } div.debug *{ font-family(Trebuchet MS,Arial !important) margin(0) }');debug->lasso("<?LassoScript define_tag('MyTag',-optional = 'thing') // My comment local('output') = string + #thing; return(#output) /define_tag;?>");debug->html('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>L-Debug - Example</title></head><body bgcolor="#ebead5"> <!-- HTML Comment--> <p>Hello World</p> </body></html>');//debug->ashtml;?></body></html>