Skip to content

Commit 043cb79

Browse files
author
Jason Smith
committed
More documentation and cleanup
1 parent fc4ca6e commit 043cb79

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ Rendered twigs may contain drupal tokens, which are then processed in context.
1212
## Installation
1313
Install the patternkit module as usual, and review the important variables below to determine if you would like to change the defaults.
1414

15+
Install the Twig library into /sites/all/libraries/Twig
16+
```
17+
git clone git://github.com/twigphp/Twig.git -b 1.x /tmp/Twig
18+
mv /tmp/Twig/lib/Twig ${DRUPALDIR}/sites/all/libraries/
19+
rm -rf /tmp/Twig
20+
```
21+
1522
The patternkit module by itself only provides the glue for other modules to present components. Define one by implementing ```hook_patternkit_library```
1623

1724
An example implementation follows

patternkit.info

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
name="Patternkit"
2-
description="Adds Patternkit patterns to panels as content types."
3-
package="Presentation Framework"
4-
core=7.x
1+
name = "Patternkit"
2+
description = "Adds Patternkit patterns to panels as content types."
3+
package = "Presentation Framework"
4+
core = 7.x
5+
version = 7.x-1.1
6+
57
dependencies[] = ctools
68
dependencies[] = panels
9+
710
files[] = src/PatternkitDrupalCachedLib.php
811
files[] = src/PatternkitDrupalTwigLib.php
912
files[] = src/PatternkitEditorConfig.php

src/PatternkitDrupalTwigLib.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ public function getTwigInstance() {
274274
$templatesDirectory = DRUPAL_ROOT . DIRECTORY_SEPARATOR . dirname(
275275
$module->filename
276276
);
277+
278+
// Namespacing is not necessary here, as each "engine" is unique to
279+
// the "library".
277280
$loader->addPath($templatesDirectory);
278281
}
279282
}
@@ -314,7 +317,13 @@ public function renderTwigTemplate($template, array $variables = array()) {
314317
$content = $template->render($variables);
315318
}
316319
catch (Exception $e) {
317-
$content = t('Twig error "!error"', array('!error' => $e->getMessage()));
320+
$content = t(
321+
'Twig error (!exc} "!error"',
322+
array(
323+
'!exc' => 'tst',
324+
'!error' => $e->getMessage(),
325+
)
326+
);
318327
watchdog(
319328
'patternkit',
320329
'Twig engine failure: @msg',
@@ -342,7 +351,6 @@ public function renderTwigTemplate($template, array $variables = array()) {
342351
);
343352
}
344353

345-
$content .= "poop";
346354
return $content;
347355
}
348356

0 commit comments

Comments
 (0)