Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 78 lines (62 sloc) 1.537 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
<?php
/*
* Use this to add lambdas to the Mustache view object
*/
class GimmeAsset {

public function __construct($data_obj) {
$props = get_object_vars($data_obj);
foreach($props as $key=>$val) {
$this->{$key} = $val;
}
}

public function nice_date() {
return date("l, F j, Y g:sa", $this->date);
}

public function is_image() {
return ('image' === $this->asset_type);
}

public function is_page() {
return ('page' === $this->asset_type);
}

public function is_embed() {
return ('embed' === $this->asset_type);
}

public function is_text() {
return ('text' === $this->asset_type);
}

public function is_document() {
return ('document' === $this->asset_type);
}

public function formatted_text_content() {
$text = $this->content;
$text = nl2br($text);
return $text;
}

public function formatted_description() {
$text = trim($this->description);
$text = nl2br($text);
return $text;
}


public function embed_html() {
if (!$this->is_embed()) {
return "not an embed!";
}

if (isset($this->content->info) && isset($this->content->info->html)) {
return $this->content->info->html;
}

if (!isset($this->content->attributes)) {
return "no attributes!";
}

$tag = strtolower($this->content->tag);

// build attr string
$attr_str = '';
foreach($this->content->attributes as $key=>$val) {
$key = trim($key);
$val = trim($val);
$attr_str .= "{$key}=\"{$val}\" ";
$attr_str = trim($attr_str);
}

$html = "<{$tag} {$attr_str}>";
return $html;
}
}
Something went wrong with that request. Please try again.