You are here

function module_builder_parse_template in Module Builder 5

Same name and namespace in other branches
  1. 6.2 includes/process.inc \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)

2 calls to module_builder_parse_template()
generate_module in ./module_builder.module
module_builder_page_input in ./module_builder.module
Module form: 'input' step. Collect module data.

File

./module_builder.module, line 950
Builds scaffolding for custom modules.

Code

function module_builder_parse_template($file) {
  $data = array();
  preg_match_all(MODULE_BUILDER_TEMPLATE_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;
}