<?php return html(div(array('id' => 'everything', 'class' => 'foo'), p('This is a ', strong(Sc('bold', true), 'bold'), span(Sc('bold', false), 'plain'), ' sentence.'), p(Sd('foo')), ul(Sforeach(array('asdf' => 'qwerty', 'foo' => 'bar', 'hooah' => 'woo'), li(Sd('_k'), ': ', Sd('_v'))))));
$key = $keys[0]; $value = $keys[1]; break; } $out = array(); foreach ($arr as $k => $v) { SometimesData::set($key, $k); SometimesData::set($value, $v); $s = clone $sometimes; $s->bind(); $out[] = $s; } SometimesData::delete($key); SometimesData::delete($value); return new Nil($out); } # A test, if run from the command line via `php sometimes.php` if ('cli' == php_sapi_name() && is_array($argv) && preg_match('!/' . basename(__FILE__) . '$!', realpath($argv[0]))) { # For the test, use templates in this directory $GLOBALS['SOMETIMES_TEMPLATEDIR'] = dirname(__FILE__); # Set a variable expected by foo.html.php Sd('foo', 'bar'); # Include and output foo.html.php under both possible conditions $doc = Sf('foo.html.php'); Sout($doc, Sc('bold')); echo "\n\n"; Sout($doc, Sc('bold', false)); echo "\n\n"; # Safely fail to include a non-existent file var_dump(Sf('does-not-exist.html.php')); }
<?php return Snil(form(array('action' => '/report', 'method' => 'post'), Sc('address'), h1(small('Currently: '), Sd('address'), br(), Snil(Sc('sweep', true), small('That street is swept: '), Sd('sweep'), ' ', Sif(Sc('inaccurate', true), '(inaccurate)'), Sif(Sc('inaccurate', false), small(small(input(array('type' => 'submit', 'value' => 'Report as inaccurate', 'class' => 'link')))))), Sif(Sc('sweep', false), Sc('impossible', true), small('This address was impossible to geocode')), Sif(Sc('sweep', false), Sc('impossible', false), small('Street sweeping information will be available shortly ', small(a(array('href' => '/home'), 'Refresh')))))), form(array('action' => Sd('URL'), 'method' => 'post'), p(label(array('for' => 'address'), 'My car is at...'), br(), input(array('id' => 'address', 'name' => 'address', 'type' => 'text', 'value' => Sd('new_address'), 'class' => 'text stretch')), br(), 'Only the closest street number and the street name, please.', br(), small('Don’t choose a corner address because SF GIS might return inaccurate street sweeping data. Make sure you use the proper side of the street so we can accurately predict the street sweeping schedule.')), p(input(array('type' => 'submit', 'value' => 'Update', 'class' => 'button')))), Sif(Sc('need_confirm_sms'), h2('Confirm your cell phone number for SMS'), form(array('action' => '/confirm/sms', 'method' => 'post'), p(label(array('for' => 'code'), 'SMS confirmation code:'), br(), input(array('id' => 'code', 'name' => 'code', 'type' => 'text', 'class' => 'text stretch')), br(), small('Enter the code sent to your cell phone to have reminders sent to your phone.')), p(input(array('type' => 'submit', 'value' => 'Confirm', 'class' => 'button'))))));
<?php return html(head(meta(array('http-equiv' => 'Content-Type', 'content' => 'text/html; charset=UTF-8')), meta(array('id' => 'viewport', 'name' => 'viewport', 'content' => 'width=320; initial-scale=1.0; ' . 'maximum-scale=1.0; user-scalable=0;')), title(Sc('title'), Sd('title'), ' — Where’s my car?'), title(Sc('title', false), 'Where’s my car?'), S('link', array(array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => '/css/style.css')))), body(div(array('id' => 'head'), a(array('href' => '/'), 'Where’s my car?')), div(array('id' => 'content'), h1(Sc('title'), Sd('title')), p(array('class' => 'error'), Sc('error'), Sd('error')), p(array('class' => 'status'), Sc('status'), Sd('status')), p(array('class' => 'success'), Sc('success'), Sd('success')), Sl()), div(array('id' => 'foot'), p(Sc('logged_in'), a(array('href' => '/logout'), 'Logout')), p('By ', a(array('href' => 'http://rcrowley.org/'), 'Richard Crowley')))));
<?php Sd('title', 'Confirm your cell phone number'); return Snil(p(Sc('confirm', true), array('class' => 'success'), 'Thanks!'), p(Sc('confirm', false), array('class' => 'error'), 'The codedidn’t match.'), p(a(array('href' => '/home'), 'Home')));