Update src/PHPWord/Template.php

This function returns array of all variables in template.
Test code:
$PHPWord = new PHPWord();
$document = $PHPWord->loadTemplate('Template.docx');
var_dump($document->getVariables());
This commit is contained in:
SergeC 2012-08-11 23:02:57 +03:00
parent 4f457c99e6
commit 9d6b2ff7bd
1 changed files with 8 additions and 1 deletions

View File

@ -91,7 +91,14 @@ class PHPWord_Template {
$this->_documentXML = str_replace($search, $replace, $this->_documentXML);
}
/**
* Returns array of all variables in template
*/
public function getVariables()
{
preg_match_all('/\$\{(.*?)}/i', $this->_documentXML, $matches);
return $matches[1];
}
/**
* Save Template
*