holantomas/semantic

Tool for create semantic websites

0.4 2017-02-01 20:50 UTC

This package is auto-updated.

Last update: 2024-04-21 18:51:32 UTC


README

Downloads this Month Latest Stable Version

This extension is here to provide HTML Document api for Nette Framework.

Installation

Composer package is not prepared yet

The best way to install is using Composer:

$ composer require holantomas/semantic

Register extension in neon config

extensions:
	semantic: holantomas\Semantic\Bridges\Nette\SemanticExtension

You can setup your own IDocument implementation.

semantic:
	document: namespace\to\your\document # Or false to disble it

If you have your implementation of IDocument you have to specify @required annotation for document properties which will cause warnings when are empty or NULL. You don't have to care about properties visibility

use holantomas\Semantic\IDocument;

class MyDocument implements IDocument {

	/**
	 * @var string
	 * @required - this make property required (throws warnings)
	 */
	private $title = '';

}

Enable Tracy panel(optional) - if is Tracy panel disabled, document throws E_USER_WARNING after render on @required properties which are NULL or empty

tracy:
	bar:
		- holantomas\Semantic\Bridges\Tracy\SemanticPanel

For show properties in panel you have to specify @panel on every property.

use holantomas\Semantic\IDocument;

class MyDocument implements IDocument {

	/**
	 * @var string
	 * @required - this make property required (throws warnings)
	 * @panel - this make property show in tracy panel
	 */
	private $title = '';

}

annotations can be customized by Checker::$REQUIREMENT_ANNOTATION and SemanticPanel::$RENDER_ANNOTATION

Usage

Document is automaticly registered as service and insert to presenter template param named as document. You don't have to do $this->template->document = $this->document; in presenter.

namespace App;

use Nette\Application\UI\Presenter;
use holantomas\Semantic\IDocument;

class BasePresenter extends Presenter
{
	/** @var IDocument @inject */
	public $document;
	
}

class ExamplePresenter extends BasePresenter
{
	public function actionDefault(){
		$this->document->setTitle('Hello world!');
	}
	
}
<html>
	<head>
		<title>{$document->getTitle()}</title>
		...
	</head>
	...
</html>

Of course you can autowire document to all services or components and modify properties.

Open graph and tests coming soon