Git Product home page Git Product logo

blade-extensions's People

Contributors

aleemb avatar dweineratl avatar haleksandre avatar robinradic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blade-extensions's Issues

BLADE-4 ⁃ Multi line @include suggestion

That looks like a promising extension!

The multi line array definition enlightened me that I always wanted a multi line @include, but in plain blade it is not possible, as far as I know.

So instead of this:

@include('some.route', array('a'=>'bunch','of'=>'parameters','to'=>'pass','on'=>'here','in'=>'only','one'=>'line')

One could use a briefer one:

@include('some.route', array(
    'a'=>'bunch',
    'of'=>'parameters',
    'to'=>'pass',
    'on'=>'here',
    'but'=>'in',
    'multiple'=>'lines')

Please consider this idea, and good work finishing the extension!

BLADE-6 ⁃ Loop not working for related collections

When you are using eager loading with eloquent for example and u want to write this:

@foreach($foo->bar as $item)

the extension will pick up $foo instead of $foo->bar

this can be fixed by add '->' to the regex for openForEach function:
line 72 of BladeExtender.php

$matcher = '/@foreach(\s?)\(\$(.[0-9a-zA-Z_\->]+)(\s?)(.*)\)/';

BLADE-5 ⁃ Some thoughts about @debug

When I want to quickly debug my view, I usually end up using this line of code:

<pre><code>{{ dd($val) }}</code></pre>

If I understand right the current proposal of @debug, now it would look like this:

<pre><code>
@debug($val)
</code></pre>

Which is still too much to type...

I think in most cases one would need the <code> and <pre> tags for a nice output, so please consider including those in @debug, so it would do the job alone for debugging:


@debug($val)

BLADE-34 ⁃ Macro not working

Updated composer.json (set blade-extensions to >=6.0)
composer dump-autoload
composer update

did php artisan vendor:publish --provider=Radic\BladeExtensions\BladeExtensionsServiceProvider which gave me nothing to publish for tag []

duplicated the config file blade_extensions.php under "project/config/"

Added into my view at first lines the exemple with @macro('alert')
Thrown me :

Argument 4 passed to Radic\BladeExtensions\Directives\MacroDirectives::directiveMacro() must implement interface Illuminate\Contracts\Foundation\Application, instance of Illuminate\View\Compilers\BladeCompiler given, called in /Applications/AMPPS/www/inMindBO/vendor/radic/blade-extensions/src/Traits/BladeExtenderTrait.php on line 63 and defined

in MacroDirectives.php line 38
at HandleExceptions->handleError('4096', 'Argument 4 passed to Radic\BladeExtensions\Directives\MacroDirectives::directiveMacro() must implement interface Illuminate\Contracts\Foundation\Application, instance of Illuminate\View\Compilers\BladeCompiler given, called in /Applications/AMPPS/www/inMindBO/vendor/radic/blade-extensions/src/Traits/BladeExtenderTrait.php on line 63 and defined', '/Applications/AMPPS/www/inMindBO/vendor/radic/blade-extensions/src/Directives/MacroDirectives.php', '38', array('value' => '@macrodef('alert') ', 'pattern' => false, 'replacement' => object(Application))) in MacroDirectives.php line 38
at MacroDirectives->directiveMacro('@macrodef('alert') ', false, object(Application), object(BladeCompiler)) in BladeExtenderTrait.php line 63
at MacroDirectives::Radic\BladeExtensions\Traits{closure}('@macrodef('alert') ', object(BladeCompiler))
at call_user_func(object(Closure), '@macrodef('alert') ', object(BladeCompiler)) in BladeCompiler.php line 185
at BladeCompiler->compileExtensions('@macrodef('alert') ') in BladeCompiler.php line 169
at BladeCompiler->parseToken(array('314', '@macrodef('alert') ', '1')) in BladeCompiler.php line 143

BLADE-58 ⁃ Minify not working

Hi,

I would ask why the package doesn't work for the @minify.
The example:

<script>
    @minify('js')
    var exampleJavascript = {
        this: 'that',
        foo: 'bar',
        doit: function(){
            console.log('yesss');
        }
    };
    @endminify
</script>

After compiled stays the same.

BLADE-25 ⁃ After Update to Laravel 5.1 and blade-extensions got errors

After Update to Laravel 5.1 and blade-extensions, I got errors

FatalErrorException in DebugDirectives.php line 37:
Call to undefined method Illuminate\View\Compilers\BladeCompiler::createPlainMatcher()

in DebugDirectives.php line 37
at FatalErrorException->__construct('message' => ''Call to undefined method Illuminate\View\Compilers\BladeCompiler::createPlainMatcher()'', 'code' => '1', 'severity' => '0', 'filename' => ''D:\dev\project\vendor\radic\blade-extensions\src\Directives\DebugDirectives.php'', 'lineno' => '37', 'traceOffset' => '0', 'traceArgs' => '') in HandleExceptions.php line 127
at HandleExceptions->fatalExceptionFromError('error' => 'array ('type' => 1, 'message' => 'Call to undefined method Illuminate\View\Compilers\BladeCompiler::createPlainMatcher()', 'file' => 'D:\dev\project\vendor\radic\blade-extensions\src\Directives\DebugDirectives.php', 'line' => 37)', 'traceOffset' => '0') in HandleExceptions.php line 112
at HandleExceptions->handleShutdown() in HandleExceptions.php line 0
at DebugDirectives->addBreakpoint('value' => ''<div clas.....

BLADE-29 ⁃ Issue with multiple @render

Hi,

It looks like the following code doesn't work as expected.

<form method="@render('formMethod', 'POST')" action="@render('formAction', 'd')" id="@render('formId', 'modalForm')">

I got "syntax error, unexpected '" action="' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';'"

When I look at the actual php file (compiled), I see the following php.

<form method="<?php echo \Radic\BladeExtensions\Helpers\Partial::renderBlock('formMethod', 'POST')" action="@render('formAction', 'd'); ?>"
                id="<?php echo \Radic\BladeExtensions\Helpers\Partial::renderBlock('formId', 'modalForm'); ?>">

As you see the @render for the 'action' didn't get converted.

Am I doing something wrong?

BLADE-60 ⁃ @push to parent extends inside @embed

Hi,

would be great to be able to @push something from the @embed directive to the parent.
Example:
component.blade.php

@yield('content')
@push('js')
  <script>alert('pushed 1!');</script>
  @stack('js')
@endpush

layout.blade.php

@yield('content')
@stack('js')

page.blade.php

@extends('layout')
@section('content')
  @embed('component')
    Should push two scripts!
    @push('js')
      <script>alert('pushed 2!');</script>
    @endpush
  @endembed
@endsection

BLADE-39 ⁃ @foreach() runs multiple queries

Hi again.

I found another bug in BladeExtensions.

@foreach(App\Office::all() as $office)
@endforeach

runs 2 queries

select * from `offices` 
select * from `offices` 

If I disable Radic\BladeExtensions\BladeExtensionsServiceProvider
it runs just one unique query.

Can you explain this behaviour? Thanks

BLADE-30 ⁃ @embed args problem

Thanks for great blade extension!

I want to call @embed with method.

Blade code 
@embed('form', $model->getNameOptions())@endembed

But error has occurred.

compiled code
syntax error, unexpected ';'
<?php app('blade.embedding')->open('form', $model->getOptions()->insert(<<<'EOT'
)
EOT
)->close(); ?>

Can you fix this problem?

BLADE-21 ⁃ Laravel 5.0.32 Update Break

After I update to laravel 5.0.32. I found this error.

PHP Warning: Uncaught exception 'ErrorException' with message 'require(D:\dev\project\vendor\radic\blade-extensions\src\resources\config\blade_extensions.php): failed to open stre
am: No such file or directory' in D:\dev\project\vendor\laravel\framework\src\Illuminate\Support\ServiceProvider.php:64

So, I work around by copy resources folder into the src folder.

Please help to fix.

BLADE-7 ⁃ Error on last composer update 1.2.0

Hello, when i upgrade from 1.1.1 to 1.2.0:

Class 'Radic\BladeExtensions\Extensions\ForEachManager' not found

On blade template:

@if(!$loop->last),@endif

Downgrade fix the problem.

However great extension!
Regards.

BLADE-55 ⁃ warning message when using branch 3.0 on laravel 5.0

arning: Ambiguous class resolution, "Radic\BladeExtensions\Facades\Markdown" was found in both "/var/www/vhosts/singlejatt.com/httpdocs/singlejatt5/vendor/radic/blade-extensions/src/Facades/Markdown.php" and "/var/www/vhosts/singlejatt.com/httpdocs/singlejatt5/vendor/radic/blade-extensions/src/Facades/BladeString.php"

BLADE-62 ⁃ Laravel 5 support for all major versions

Ensure Blade Extensions supports Laravel versions: 5.0 / 5.1 / 5.2 / 5.3

Currently the idea is to let the config file define which directives to disable/override using the version_overrides key.

return [
    'mode'                => 'auto',
    'directives'          => [
        'set'   => 'Radic\\BladeExtensions\\Directives\\SetDirective',
        'unset' => 'Radic\\BladeExtensions\\Directives\\UnsetDirective',

        'breakpoint' => 'Radic\\BladeExtensions\\Directives\\BreakpointDirective',
       // etc..
    ],
    // Laravel version changes to support all larael versions
    'version_overrides'   => [
        '5.0' => [
            'breakpoint' => 'Radic\\BladeExtensions\\Directives\\Breakpoint50Directive'
        ],
        '5.1' => [
            'breakpoint' => null // 'disabled' the directive
        ],
        '5.2' => [],
        '5.3' => []
    ],
    'disabled_directives' => [
        'debug',
    ],
    'overrides'           => [
        'debug' => [
            'pattern'     => '',
            'replacement' => '',
        ],
    ],
];

This should also fix #58

BLADE-38 ⁃ @include is not working inside @embed

I have this code

@embed('inspinia.box')
    @section('title','Edit User')
    @section('content')
        @include('admin.users._form')
    @endsection()
@endembed

it is failing with this error message:
Call to undefined method Radic\BladeExtensions\Helpers\EmbedStack::make()
at line:4

 2:   <?php $__env->startSection('title','Edit User'); ?>
 3:   <?php $__env->startSection('content'); ?>
 4:   <?php echo $__env->make('admin.users._form', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
 5:   <?php $__env->stopSection(); ?>



BLADE-61 ⁃ v3.0 Broken Dependancy Tree?

Hi there,

I'm trying to use an older version of the package (v3.0) as we currently only support Laravel 5.0. When I do a composer update I get the following

screen shot 2016-09-23 at 09 41 24

Looking at the composer.json for v3 you can see the dependancy as follows

screen shot 2016-09-23 at 09 41 34

However checking on Packagist here it only shows v1.0.0 which requires PHP >= 5.5.9? See below...

screen shot 2016-09-23 at 09 44 56

This means that v3.0 can never be installed as it can't resolve a dependancy which doesn't exist. Am I missing something or has support for v3.0 been dropped?

Thanks

BLADE-59 ⁃ Nest @minify inside another @minify

Hi,

would be great if you can nest the @minify directive inside another @minify directive, as below:
some.blade.php

@minify('html')
  <div>
    <h4>Yayyyy!</h4>
  </div>
@endminify

main.blade.php

<script>
  @minify('js')
    var html = "@include('_some')";
  @endminify
</script>

Thanks!

BLADE-48 ⁃ [feature] PHPStorm / IDEA support

Any project using PHPStorm/Idea can have a .idea/blade.xml file that configures custom blade directives. I've been adding them manually for many, many times now.

This could easily be done with a console command like blade-extensions:phpstorm that'll add the blade directives. Doesn't even require the IDE to restart, works directly.

BLADE-27 ⁃ Markdown Issues

Hi, after installing this package

I started to have issues with @GrahamCampbell's Markdown package

https://github.com/GrahamCampbell/Laravel-Markdown

Upon further investigation it is due to the markdown features blade-extensions provide, hence I removed Laravel-Markdown and included "erusev/parsedown": "~1.5".

I change my blade template from

Markdown::convertToHtml(e($comment->body))

to

@markdown
{{$comment->body}}
@endmarkdown

However what I got instead was

<?php echo $comment->body; ?>

in my view. Would like to ask if I used the @markdown tag wrongly.

BLADE-22 ⁃ Set is not allow some of expression.

@set does not allow some of expression.

Eg.
@set('somevar',$object->getValue())
@set('somevar',$object->getValue('params'))
@set('somevar',somefunctionCall('Params'))
@set('somevar',Session::get('Params'))

Once I've use the expression above, It has nothing compiled in compiled template file and of cause it has no variable setting.

still not work around, please help to fix.

BLADE-26 ⁃ @macro rendered in view again

I'm sorry for the issue but even with the latest comit, I always have this error. I copied pasted the file you edited in the latest commit into vendor/radic/blade-extensions/src/

It renders this when I call @domacro('test', 'hey') :

@macro('test', $test) return ''; @endmacro @domacro('test', 'hey')

my index.blade.php containing :

@macro('test', $test)
    return '<img src="' . $test . '" />';
@endmacro

When I keep '\Radic\BladeExtensions\Directives\MacroDirectives::attach($this->app)' in AppServiceProvider.php, I have the error
When I remove '\Radic\BladeExtensions\Directives\MacroDirectives::attach($this->app)' in AppServiceProvider.php, I have the error
I also renamed the form alias to 'form' or 'Form' and it doesn't change anything

BLADE-63 ⁃ Extendable Directives and easy swapping of Directives

Directives should be extendable and Blade Extensions should provide an easy way of adding, extending, replacing or removing directives. Something along the lines of

config/blade-extensions.php

return [
    'directives'          => [
        'set'   => 'Radic\\BladeExtensions\\Directives\\SetDirective',
        'unset' => 'Radic\\BladeExtensions\\Directives\\UnsetDirective',
        'breakpoint' => 'Radic\\BladeExtensions\\Directives\\BreakpointDirective',
        // etc ..
    ],
    // other config ..
]

Classes

interface DirectivesRegistry {
    public function set($name, $handler = null)
    public function call($name)
}
abstract class Directive
{
    protected $pattern;
    protected $replace;
    protected $name;

    public function handle($value){}
    // getters, setters eg getPattern, setPattern, etc
}

class BreakpointDirective extends Directive
{
    // @NAME is replaced by config key name
    protected $pattern = '/(?<!\\w)(\\s*)@NAME(\\s*)/';

    protected $replace = <<<'EOT'
<!-- breakpoint --><?php
if(function_exists('xdebug_break')){
    var_dump(xdebug_break());
}
?>
EOT;
}

Implementation

foreach($config->get('blade-extensions.directives',[]) as $name => $handler){
    /** @var {DirectivesRegistry} $registry */
    $registry->set($name, $handler)
}
$registry->call('breakpoint')->handle('string with @breakpoint')

BLADE-32 ⁃ @embedGlobal

Hi
macro @embed is great. - Thank you

What about creating new macro @embedglobal - embed with global context which can directly access global variables in template?
Similar as {% embed %} in TWIG, where this is standard behaviour

Thanks you.

BLADE-13 ⁃ Space in @foreach

Good evening! There is a small problem, if you write @foreach with a space before the parenthesis is the regular expression does not work. It would be nice to fix it. Thank U! I am sorry for my english)

BLADE-42 ⁃ Incompatible with other directives that use `$__env`

Out of the box code generated from blade templates includes the variable $__env, assigned to an instance of Illuminate\View\Factory.

When using blade-extensions $__env is assigned to an instance of Radic\BladeExtensions\Helpers\EmbedStack. This class has most of the same methods as Illuminate\View\Factory, but it does not have them all. I have a directive that uses $__env->hasSection($section). This method is not in the Radic\BladeExtensions\Helpers\EmbedStack class.

To ensure the default behavior of $__env is maintained when using blade-extensions the following could be added to Radic\BladeExtensions\Helpers\EmbedStack.

    /**
     * Dynamically call the view factory instance.
     *
     * @param  string  $method
     * @param  array   $parameters
     * @return mixed
     */
    public function __call($method, $parameters)
    {
        return call_user_func_array([$this->viewFactory, $method], $parameters);
    }

BLADE-16 ⁃ The error in the location of config / blade_extensions.php

Good day!
When the composer update pops up an error:

Error Output: PHP Warning:  Uncaught exception 'ErrorException' with message 'require(/mysite/vendor/radic/blade-extensions/src/resources/config/blade_extensions.php): failed t  
  o open stream: No such file or directory' in /mysite/vendor/laravel/fra  
  mework/src/Illuminate/Support/ServiceProvider.php:64 

I decided to move a folder in the appropriate directory.

BLADE-11 ⁃ Documentation for using loop data

It is not exactly clear how to go about accessing the loop data described in the documentation, or what particular use cases exist.

I've tried to access it as shown in the documentation (see below). However, I get a Trying to get property of non-object error.

@foreach($stuff as $key => $val)
    $loop->index;       // int, zero based
    $loop->index1;      // int, starts at 1
    $loop->revindex;    // int
    $loop->revindex1;   // int
    $loop->first;       // bool
    $loop->last;        // bool
    $loop->even;        // bool
    $loop->odd;         // bool
    $loop->length;      // int
@endforeach

Am I missing something?

Thanks

BLADE-64 ⁃ Drop build-in Markdown compiler/renderer, rely on custom / 3rd party integration

Compiling markdown / adding markdown engine is outside of the package its scope. This can better be achieved by using interfaces which allow integration of custom parsers or parsers from other markdown packages.

A default markdown parser class should be added that (optinally / composer suggest) depends on a external parser library like Cebe Markdown to keep providing the @markdown directive

BLADE-14 ⁃ Using @set right after @foreach throws FatalErrorException

Using @set right after @foreach throws FatalErrorException in daf5b1ff7385a6726aacd9e899b61add line 42: syntax error, unexpected '<'

For example:

@foreach( $categories as $c )
@set('products_cnt', count($c->products))

throws error, but putting @set within any tag

@foreach( $categories as $cat )
<i>@set('products_cnt', count($c->products))</i>

works just fine

BLADE-37 ⁃ @embed is not working. FIle Not Found, but is there

I'm running a homestead server. I'm on 6.0.1 and on Laravel v5.1.17.

resources/views/home.blade.php:

@section('content')

@embed('test')
    @section('body')
        <p>hello world</p>
    @stop
@endembed

@stop

resources/views/test.blade.php:

test
@yield('body')

I keep getting a File Not Found Exception.

FileNotFoundException in Filesystem.php line 381:
File not found at path: home/vagrant/Brandon/playground/resources/views/test.blade.php
in Filesystem.php line 381
at Filesystem->assertPresent('home/vagrant/Brandon/playground/resources/views/test.blade.php') in Filesystem.php line 176
at Filesystem->read('/home/vagrant/Brandon/playground/resources/views/test.blade.php') in FilesystemAdapter.php line 56
at FilesystemAdapter->get('/home/vagrant/Brandon/playground/resources/views/test.blade.php') in EmbedStack.php line 107
at EmbedStack->getViewFileContent() in EmbedStack.php line 117
at EmbedStack->getBladeCompiledViewFileContent() in EmbedStack.php line 73
at EmbedStack->end() in Stacker.php line 95
at Stacker->end() in 463c15d2b82dcde93063ea8acb851a8a line 34

Any ideas?

BLADE-56 ⁃ php 7 and PREG_JIT_STACKLIMIT_ERROR

So I have been delving into your code this evening to find out that JIT PCRE compiler ran into a stacklimit error. This caused the problem that no embed tags were replaced anymore and were showing up as cleartext on the page. Aside from probably documenting this to prevent other people from running into it you could perhaps test the preg_last_error() before wildly assuming it worked.

Great package by the way.

For those seeking a solution:

ini_set('pcre.jit', false);

BLADE-24 ⁃ @macro rendered in views

Hello,

Here's my composer
"php": ">=5.5.9",
"laravel/framework": "5.1.",
"illuminate/html": "5.
",
"kozz/laravel-guzzle-provider": "6.0",
"caouecs/laravel4-lang": "~2.0",
"nesbot/carbon": "~1.14",
"radic/blade-extensions": "~4.0",
"laravelcollective/html": "5.1.*",
"raveren/kint": ">=0.9.1",
"erusev/parsedown": "~1.5"

I added in config/app.php for providers :
Collective\Html\HtmlServiceProvider::class,
Radic\BladeExtensions\BladeExtensionsServiceProvider::class

I added aliases:
'Form' => Collective\Html\FormFacade::class,
'HTML' => Collective\Html\HtmlFacade::class,

My template contains :
@macro('simple', $first, $second = 3, $what)
$who = $first . $second;
return $what . $who;
@endmacro

which is rendered as text with @domacro('simple')

Laravel 5.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.