$theme['ui_bg'] = $theme['background']; } // Include non-hashed colours. $theme = hashLessify($theme); // Iterate patterns. foreach (globArray($patternDirs) as $patternPath) { // This is a good place to show progress. echo '.'; // Load the pattern configuration JSON. $patternConfig = readJson($patternPath); // Build a path to the pattern source. $sourcePath = str_replace('.json', '.pattern', $patternPath); // Load the pattern source from disk. $patternSource = file_get_contents($sourcePath); // Use 'Twig' to render the theme from theme data. $result = renderTwig($patternSource, $theme); // Build the write path stub from pattern config. $writePath = $outputDir . '/' . $patternConfig['folder'] . '/'; // If a theme config has a directory set... if (isset($theme['theme']['dir'])) { // ... append it to the write path. $writePath .= $theme['theme']['dir'] . '/'; } // Ensure that the directory exists. @mkdir($writePath, 0777, true); // Attach the file name and extension from config to the write path. $writePath .= $theme['theme']['slug'] . $patternConfig['extension']; // Write the theme file to disk. file_put_contents($writePath, $result); } }
include __DIR__ . '/../include/nav.php'; ?> <?php ob_start(); ?> <h1>Raptor Editor - Data Token Example</h1> <p> Hello {{ person.name }} </p> {% for transaction in transactions %} <p>{{ transaction }}</p> {% endfor %} <?php $data = ['person' => ['name' => 'John Smith'], 'transactions' => [1025.99, 499.99, 35.0, -100.0]]; $source = renderContent(ob_get_clean(), $content, 'body-1'); $html = renderTwig($source, $data); ?> <div class="editable half center" data-id="body-1" data-source="<?php echo base64_encode($source); ?> " data-data='<?php echo json_encode($data); ?> '> <?php echo $html; ?> </div> </body> </html>