Skip to content

Instantly share code, notes, and snippets.

@hawkeyetwolf
Last active March 18, 2017 00:34
Show Gist options
  • Save hawkeyetwolf/a98c23b1ab444cd4fc5ba377d63ed8d3 to your computer and use it in GitHub Desktop.
Save hawkeyetwolf/a98c23b1ab444cd4fc5ba377d63ed8d3 to your computer and use it in GitHub Desktop.
Twigshim example: Using json mock data to populate a component
/**
* 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