<commit_before><?php

namespace Rikiless\BreadcrumbComponent;

use Nette;

/**
 * Basic component rendering responsive breadcrumb
 *
 * @author <NAME> <<EMAIL>>
 */
class Control extends Nette\Application\UI\Control
{

	/** @var Nette\Localization\ITranslator */
	private $translator;

	/** @var array */
	private $homepage = [];

	/** @var array */
	private $items = [];



	public function __construct(Nette\Localization\ITranslator $translator = NULL)
	{
		$this->translator = $translator;
	}



	public function setHomepage($name = '', $link = '')
	{
		if ($this->translator) {
			$name = $this->translator->translate($name);
		}

		$this->homepage = [
			'name' => $name,
			'link' => $link
		];

		return $this;
	}



	public function add($name = '', $link = '')
	{
		if ($this->translator) {
			$name = $this->translator->translate($name);
		}

		$this->items[] = [
			'name' => $name,
			'link' => $link
		];

		return $this;
	}



	public function render()
	{
		$this->template->homepage = !empty($this->homepage) ? $this->homepage : [
			'name' => 'Home',
			'link' => $this->presenter->link('Homepage:default')
		];
		$this->template->items = $this->items;
		$this->template->backLink = (count($this->items) >= 2 and !empty($this->items[count($this->items)-2]['link'])) ? $this->items[count($this->items)-2] : FALSE;
		$this->template->setFile(__DIR__. '/templates/breadcrumb.latte');
		$this->template->render();
	}

}<commit_msg>add option to use custom template<commit_after><?php

namespace Rikiless\BreadcrumbComponent;

use Nette;

/**
 * Basic component rendering responsive breadcrumb
 *
 * @author <NAME> <<EMAIL>>
 */
class Control extends Nette\Application\UI\Control
{

	/** @var Nette\Localization\ITranslator */
	private $translator;

	/** @var array */
	private $homepage = [];

	/** @var array */
	private $items = [];

	/** @var string */
	private $customTemplate;



	public function __construct(Nette\Localization\ITranslator $translator = NULL)
	{
		$this->translator = $translator;
	}



	public function setTemplate($path)
	{
		$this->customTemplate = $path;
	}



	public function setHomepage($name = '', $link = '')
	{
		if ($this->translator) {
			$name = $this->translator->translate($name);
		}

		$this->homepage = [
			'name' => $name,
			'link' => $link
		];

		return $this;
	}



	public function add($name = '', $link = '')
	{
		if ($this->translator) {
			$name = $this->translator->translate($name);
		}

		$this->items[] = [
			'name' => $name,
			'link' => $link
		];

		return $this;
	}



	public function render()
	{
		if ($this->customTemplate == FALSE) {
			$this->customTemplate = __DIR__. '/templates/breadcrumb.latte';
		}

		$this->template->homepage = !empty($this->homepage) ? $this->homepage : [
			'name' => 'Home',
			'link' => $this->presenter->link('Homepage:default')
		];
		$this->template->items = $this->items;
		$this->template->backLink = (count($this->items) >= 2 and !empty($this->items[count($this->items)-2]['link'])) ? $this->items[count($this->items)-2] : FALSE;
		$this->template->setFile($this->customTemplate);
		$this->template->render();
	}

}
{'fraction_non_alphanumeric': 0.20486555697823303, 'fraction_numerical': 0.0019206145966709346, 'mean_word_length': 3.7205438066465257, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5516817', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1077, 'n_words': 195}