Sha256: 6ed11112e36a33f24c31f4248bb9c65a70e6e4edca80b05584fd54265e081b56

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

<?php
//
//

function h($html) {
  return htmlentities($html, ENT_QUOTES);
}

function i($src) {
  $as = array('src' => url_for_image($src));
  return empty_tag('img', $as);
}

function r() {
  
}

function current_or_subpage($page) {
  
}

//
// Asset URLs

function url_for_image($image) {
  return url_for_asset($image, 'javascripts');
}

function url_for_stylesheet($stylesheet) {
  return url_for_asset($stylesheet, 'stylesheets');
}

function url_for_javascript($js) {
  return url_for_asset($js, 'javascripts');
}

function url_for_asset($what, $where) {
  return SITE_ROOT . "/$where/$what";
}

//
// Tag Helpers

function stylesheet_link_tag($css, $options = array()) {
  $options['href'] = url_for_stylesheet($css);
  $options['rel'] = 'stylesheet';
  $options['type'] = 'text/css';
  return tag('link', '', $options);
}

function javascript_include_tag($js, $options = array()) {
  $options['src'] = url_for_javascript($js);
  $options['type'] = 'text/javascript';
  return tag('script', '', $options);
}

function tag($tag, $content, $attribs = array()) {
  $attribs = attribute_list($attribs);
  return "<{$tag}{$attribs}>{$content}</{$tag}>";
}

function empty_tag($tag, $attribs = array()) {
  $attribs = attribute_list($attribs);
  return "<{$tag}{$attribs}/>";
}

function attribute_list($attribs) {
  $out = '';
  foreach ($attribs as $k => $v) {
    $v = h($v);
    $out .= " $k='$v'";
  }
  return $out;
}
?>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jaz303-site-skel-0.1.0 layouts/php/_offsite/lib/helpers.php