You are here

function module_builder_parse_template in Module Builder 6.2

Same name and namespace in other branches
  1. 5 module_builder.module \module_builder_parse_template()
  2. 7 includes/process.inc \module_builder_parse_template()

Parse a module_builder template file.

Template files are composed of several sections in the form of:

== START [title of template section] == [the body of the template section] == END ==

Parameters

string $file: The template file to parse

Return value

Array Return array keyed by hook name, whose values are of the form: array('template' => TEMPLATE BODY)

3 calls to module_builder_parse_template()
module_builder_get_templates in includes/generate.inc
Helper function for module_builder_generate_module
module_builder_page_input in includes/module_builder.pages.inc
Xmodule_builder_page_input in ./module_builder.module
Module form: 'input' step. Collect module data.

File

includes/process.inc, line 295
Module builder code processing code.

Code

function module_builder_parse_template($file) {
  $data = array();

  // Captures a template name and body from a template file.
  $pattern = '#== START (.*?) ==(.*?)== END ==#ms';
  preg_match_all($pattern, $file, $matches);
  $count = count($matches[0]);
  for ($i = 0; $i < $count; $i++) {
    $data[$matches[1][$i]] = array(
      #'title' => $matches[1][$i],
      'template' => $matches[2][$i],
    );

    /*
    $hook_custom_declarations[] = array(
      'title' => $matches[1][$i],
      'data' => $matches[2][$i]
    );
    */
  }
  return $data;
}