项目作者: ikkez

项目描述 :
A collection of template directives for the PHP Fat-Free Framework
高级语言: PHP
项目地址: git://github.com/ikkez/f3-template-directives.git
创建时间: 2018-05-12T16:37:25Z
项目社区:https://github.com/ikkez/f3-template-directives

开源协议:GNU General Public License v3.0

下载


Template directives

Collection of different template directives for the PHP Fat-Free Framework.

This package gives you a base to write your own template tag handler (directive) easily. Therefore extend the \Template\TagHandler class and implement its build method.
You can also have a look at the included, ready-to-use directives:

form

A collection of additional form-related HTML tag handlers for server side data handling to form / input / select / textarea elements.

Init:

  1. \Template\Tags\Form::initAll();

This automatically registers the following directives: input, select, option, textarea, form.

Any data you set to the global POST variable is filled into the registered form elements accordingly. If you want to use a different hive key, you can do it like this:

  1. // change source key
  2. $f3->copy('POST','form1');
  3. \Template\Tags\Form::instance()->setSrcKey('form1');

You can also fill the form fields dynamically based on the form name attribute:

  1. <form name="contact">

The field target is then set to FORM.contact:

  1. $f3->copy('POST','FORM.contact');
  2. \Template\Tags\Form::instance()->setDynamicSrcKey(true);

For more tests, see: http://f3.ikkez.de/formtest

markdown

Convert inline markdown text or render a file.

  1. <markdown>
  2. # Headline
  3. You can write **markdown** here
  4. </markdown>

or

  1. <markdown src="path/to/file.md" ></markdown>

Init:

  1. \Template\Tags\Markdown::init('markdown');

image

Render image thumbnails automatically.

Init:

  1. \Template\Tags\Image::init('image' [, $tmpl [, $options ] ] );

Options:

  • temp_dir, public accessable path for generated, temporary thumbnail images
  • file_type, default file type for dumped images, png, jpeg, gif or wbmp
  • default_quality, image quality, 0-100
  • not_found_fallback, fallback path for missing images
  • not_found_callback, define a callable function here that is executed when the image path was not found. The function receives the $filePath as first parameter.

Usage:

  1. <image src="path/to/image.jpg" width="200" ></image>

Additional attributes:

  • width, target image width
  • height, maximum image height
  • crop, allow image to be cropped into width/height ratio
  • enlarge, size up image when source image is smaller than target size
  • quality, overwrite default quality

Licence

GPLv3