2017 © Pedro Peláez
 

library blade

The Simple Framework.

image

cinnamonlab/blade

The Simple Framework.

  • Monday, August 17, 2015
  • by hajime3333out
  • Repository
  • 4 Watchers
  • 0 Stars
  • 157 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 24 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

WordPress Blade

Brings Laravel's great template engine, Blade, to WordPress. Just install and start using blade in your theme., (*1)

Blade is the template engine for Laravel, a very popular php framework, developed by Taylor Otwell. This plugin brings the same template engine to WordPress. Using a template engine will result in much cleaner template files and quicker development. Normal php can still be used in the template files. The plugin also adds a WordPress specific snippet to blade. Check out the examples for more info., (*2)

WordPress Repository: Blade, (*3)

Blade Tutorial on YouTube: Video Tutorial, (*4)

Echo/Print

// Normal


// Blade
{{ $foo }}

Post Data

// Normal


// Blade
{{ the_title() }}

If Statements

Normal, (*5)

<?php if( has_post_thumbnail() ) : ?>
    <?php the_post_thumbnail() ?>
<?php else: ?>
    <img src="<?php bloginfo( 'stylesheet_directory' ) ?>/images/thumbnail-default.jpg" />
<?php endif; ?>

Blade, (*6)

@if( has_post_thumbnail() )
    {{ the_post_thumbnail() }}
@else
    <img src="{{ bloginfo( 'stylesheet_directory' ) }}/images/thumbnail-default.jpg" />
@endif

WordPress Loop

Normal, (*7)

<ul>
    <?php $query = new WP_Query( array( 'post_type' => 'post' ) ); ?>
    <?php if ( $query->have_posts() ) : ?>
            <?php while ( $query->have_posts() ) : $query->the_post(); ?>
            <li><a href="<?php the_permalink() ?>"> <?php the_title() ?> </a></li>
            <?php endwhile; ?>
    <?php else : ?>
            <li><?php _e( 'Sorry, no posts matched your criteria.' ) ?></li>
    <?php endif; wp_reset_postdata(); ?>
</ul>

Blade, (*8)

<ul>
    @wpquery( array( 'post_type' => 'post' ) )
            <li><a href="{{ the_permalink() }}">{{ the_title() }}</a></li>
    @wpempty
            <li>{{ __( 'Sorry, no posts matched your criteria.' ) }}</li>
    @wpend
</ul>

Advanced Custom Fields

Normal, (*9)

<ul>
    <?php if( get_field( 'images' ) ): ?>
        <?php while( has_sub_field( 'images' ) ): ?>
            <li><img src="<?php the_sub_field( 'image' ) ?>" /></li>
        <?php endwhile; ?>
    <?php endif; ?>
</ul>

Blade, (*10)

<ul>
    @acfrepeater('images')
        <li>{{ get_sub_field( 'image' ) }}</li>
    @acfend
</ul>

Including Files

Files included with functions, e.g. the_header(), will not be compiled by Blade, however the php code in the file is still executed. To include a file with blade use:, (*11)

@include( 'header' )

Note that you should not type “.php”., (*12)

Layouts

master.php, (*13)

<html>
    <div class="content">
        @yield( 'content' )
    </div>
</html>

page.php, (*14)

@layout( 'master' )

@section( 'content' )


Lorem ipsum, (*15)

@endsection

Documentation

Check out the complete Blade Documentation for more examples., (*16)

Contributing

Pull requests are highly appreciated. Feel free to report a bug, typo, enhancement or a feature you want to add to the plugin., (*17)

The Versions

17/08 2015

dev-master

9999999-dev

The Simple Framework.

  Sources   Download

MIT

The Requires

 

by Hajime Hotta

framework