Skip to content
This repository has been archived by the owner on Apr 5, 2018. It is now read-only.

Commit

Permalink
Added JSON, Atom and RSS support
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Olde Hampsink committed Dec 11, 2014
1 parent a69f7d8 commit 99eaf2f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions elementtypes/TranslateElementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public function getSources($context = null)
$templates = IOHelper::getFolderContents(craft()->path->getSiteTemplatesPath(), false);
foreach($templates as $template) {

// Get path/name of html/twig/js/json files and folders
preg_match('/(.*)\/(.*?)(\.(html|twig|js)|\/)$/', $template, $matches);
// Get path/name of template files and folders
preg_match('/(.*)\/(.*?)(\.(html|twig|js|json|atom|rss)|\/)$/', $template, $matches);
$path = $matches[2];

$templateSources['templates:'.$path] = array(
Expand Down
7 changes: 5 additions & 2 deletions services/TranslateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ public function init()
// Init parent
parent::init();

// Also use html expressions for twig templates
// Also use html expressions for twig/json/atom/rss templates
$this->_expressions['twig'] = $this->_expressions['html'];
$this->_expressions['json'] = $this->_expressions['html'];
$this->_expressions['atom'] = $this->_expressions['html'];
$this->_expressions['rss'] = $this->_expressions['html'];

}

Expand Down Expand Up @@ -97,7 +100,7 @@ public function get($criteria)
if(!$isFile) {

// Set filter - no vendor folders, only template files
$filter = '^((?!vendor).)*(\.(php|html|twig|js)?)$';
$filter = '^((?!vendor).)*(\.(php|html|twig|js|json|atom|rss)?)$';

// Get files
$files = IOHelper::getFolderContents($path, true, $filter);
Expand Down

0 comments on commit 99eaf2f

Please sign in to comment.