Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit 808527d

Browse files
committed
adding render class for simple rendering of patterns
1 parent de79951 commit 808527d

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

core/lib/PatternLab/Render.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
/*!
4+
* Render Class
5+
*
6+
* Copyright (c) 2014 Dave Olsen, http://dmolsen.com
7+
* Licensed under the MIT license
8+
*
9+
* Renders the pattern, pattern header, and pattern footer for storage in PatternData::$store
10+
*
11+
*/
12+
13+
namespace PatternLab;
14+
15+
use \PatternLab\Data;
16+
use \PatternLab\PatternEngine;
17+
use \PatternLab\Template\Helper;
18+
19+
class Render {
20+
21+
/**
22+
* Renders a given pattern file using Mustache and incorporating the provided data
23+
* @param {String} the filename of the file to be rendered
24+
* @param {Array} the data related to the pattern
25+
*
26+
* @return {String} the mark-up as rendered by Mustache
27+
*/
28+
public static function Pattern($filePath,$data) {
29+
30+
$pattern = PatternEngine::$patternLoader->render($filePath,$data);
31+
return $pattern;
32+
33+
}
34+
35+
/**
36+
* Renders a given mark-up (header) using Mustache and incorporating the provided data
37+
* @param {String} the mark-up to be rendered
38+
* @param {Array} the data related to the pattern
39+
*
40+
* @return {String} the mark-up as rendered by Mustache
41+
*/
42+
public static function Header($html,$data) {
43+
44+
$header = Helper::$htmlLoader->render($html,$data);
45+
return $header;
46+
47+
}
48+
49+
/**
50+
* Renders a given mark-up (footer) using Mustache and incorporating the provided data
51+
* @param {String} the mark-up to be rendered
52+
* @param {Array} the data related to the pattern
53+
*
54+
* @return {String} the mark-up as rendered by Mustache
55+
*/
56+
public static function Footer($html,$data) {
57+
58+
$footer = Helper::$htmlLoader->render($html,$data);
59+
return $footer;
60+
61+
}
62+
63+
}

0 commit comments

Comments
 (0)