Download the PHP package xinix-technology/bono-blade without Composer
On this page you can find all versions of the php package xinix-technology/bono-blade. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xinix-technology/bono-blade
More information about xinix-technology/bono-blade
Files in xinix-technology/bono-blade
Package bono-blade
Short Description Laravel Blade template engine for Bono PHP Framework
License MIT
Informations about the package bono-blade
BonoBlade
Laravel Blade Template Engine for Bono PHP Framework
Note: BonoBlade also use Blade templating for
partialview
Installation
Add this line to your composer.json file
Configuration
Add these lines to your configuration file
If you want to change layout file name, templates path, or cache path, you can add options in your provider like this
Note: You may use any other theme based on
BladeTheme, such as blade foundation. Or you can create your own theme.
Basic usage
Layout example
Template example
Rendering template
Simply, you can render your template by call render function in \Bono\App instance.
Note: Be sure you're not adding
.blade.phpor your template will not found
Result
Rendering a page without layout
Working with sections
Note that views which extend a Blade layout simply override sections from the layout. Content of the layout can be included in a child view using the @parent directive in a section, allowing you to append to the contents of a layout section such as a sidebar or footer.
Sometimes, such as when you are not sure if a section has been defined, you may wish to pass a default value to the @yield directive. You may pass the default value as the second argument:
Including sub-views
You may also pass an array of data to the included view:
Overwriting sections
By default, sections are appended to any previous content that exists in the section. To overwrite a section entirely, you may use the overwrite statement:
The outpur is:
But if you change the second @stop to an @overwrite.
Then the following is output.
@overwrite- End a Section and Overwrite it.@stop- Stopping Injecting Content Into a Section.@show- Yielding the Current Section in a Blade Template.@append- Stopping Injecting Content into a Section and Appending It.
Extends template to be reuseable
Based on this case, your body section will be overriden by lorem ipsum and bluish content.
Other blade control structures
Echoing data
Echoing data after checking for existence
Sometimes you may wish to echo a variable, but you aren't sure if the variable has been set. Basically, you want to do this:
However, instead of writing a ternary statement, Blade allows you to use the following convenient short-cut:
Displaying raw text with curly braces
If you need to display a string that is wrapped in curly braces, you may escape the Blade behavior by prefixing your text with an @ symbol:
Of course, all user supplied data should be escaped or purified. To escape the output, you may use the triple curly brace syntax:
If you don't want the data to be escaped, you may use double curly-braces:
Note: Be very careful when echoing content that is supplied by users of your application. Always use the triple curly brace syntax to escape any HTML entities in the content.
If statements
Note: Method
@unlessis used when you want to write@if(! functionReturnBool())
Loops
Comments
Extending blade
Now you can use @dateTime($dateValue) to get your datetime value.
The createPlainMatcher method is used for directives with no arguments like @endif and @stop, while createMatcher is used for directives with arguments.
Now you can use @pre and @endpre whenever you want to print_r() your value. Just like this:
Setting the content tags blade uses
You know that blade uses {{ and }} to specify content to be output, but this conflicts with Mustache or some other library you're using.
If you want to use other tags, you can use setContentTags method. Let's say you want to use [% and %] for your tags.
Then your template can contain code like.
You can also pass a third argument as true to indicate you're setting the tags to escape content.
Then instad of using {{{ and }}} you can use [-% and %-].
Note: You must call
setContentTagsmethod before using view. The best options is: make aProviderthat preparing all of your Blade customization.