Sha256: 5d36b1bbb52e2edf46363f4412a7addc7b62e357f019bcd72ccc91d6a9975583

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 KB

Contents

<?php
/* SVN FILE: $Id: _HamlMarkdownFilter.php 51 2010-04-14 12:05:03Z chris.l.yates $ */
/**
 * Markdown Filter for {@link http://haml-lang.com/ Haml} class file.
 * This filter is an abstract filter that must be extended.
 * 
 * @author			Chris Yates <chris.l.yates@gmail.com>
 * @copyright		Copyright (c) 2010 PBM Web Development
 * @license			http://phamlp.googlecode.com/files/license.txt
 * @package			PHamlP
 * @subpackage	Haml.filters
 */

/**
 * Markdown Filter for {@link http://haml-lang.com/ Haml} class.
 * Parses the text with Markdown.
 * 
 * This is an abstract class that must be extended and the init() method
 * implemented to provide the vendorPath if the vendor class is not imported
 * elsewhere in the application (e.g. by a framework) and vendorClass if the
 * default class name is not correct.
 * @package			PHamlP
 * @subpackage	Haml.filters
 */
abstract class _HamlMarkdownFilter extends HamlBaseFilter {
	/**
	 * @var string Path to Markdown Parser
	 */
	protected $vendorPath;
	/**
	 * @var string Markdown class
	 * Override this value if the class name is different in your environment
	 */
	protected $vendorClass = 'MarkdownExtra_Parser';
	
	/**
	 * Child classes must implement this method.
	 * Typically the child class will set $vendorPath and $vendorClass
	 */
	public function init() {}

	/**
	 * Run the filter
	 * @param string text to filter
	 * @return string filtered text
	 */
	public function run($text) {
		return '<?php	'.(!empty($this->vendorPath)?'require_once "'.$this->vendorPath.'";':'').'$markdown___=new '.$this->vendorClass.'();echo  $markdown___->safeTransform("'.preg_replace(HamlParser::MATCH_INTERPOLATION, '".\1."', $text).'");?>';
	}
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
frontsau-0.0.3 lib/Phamlp/haml/filters/_HamlMarkdownFilter.php
frontsau-0.0.2 lib/Phamlp/haml/filters/_HamlMarkdownFilter.php
frontsau-0.0.1 lib/Phamlp/haml/filters/_HamlMarkdownFilter.php