Last active
March 18, 2017 00:34
-
-
Save hawkeyetwolf/a98c23b1ab444cd4fc5ba377d63ed8d3 to your computer and use it in GitHub Desktop.
Twigshim example: Using json mock data to populate a component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Overrides the theme function for the "Example" Paragraphs bundle. | |
*/ | |
function mytheme_paragraphs_item__example(&$vars) { | |
$component = 'molecules/example/example'; | |
$file = kalastatic_path_to_kalastatic() . "/src/components/$component.json"; | |
$json = file_get_contents($file); | |
$twig_template_vars = drupal_json_decode($json); | |
return twigshim_render("$component.html.twig", $twig_template_vars); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment