Git Product home page Git Product logo

laravel.smarty's Issues

Nocache doesn't seem to work in included templates

(Laravel 5)

The nocache filter and block tag don't seem to work when including templates. Putting {$smarty.now nocache} or {nocache}{$smarty.now}{/nocache} in an included template always outputs the time that the template was first run after being modified. NOTE: the same does not apply when adding the nocache attribute to the {include}.

I have caching on and compile_check enabled.

Sessions not working in Laravel 5.2.29

I am not sure why but sessions appear to not work when using Laravel Smarty views.
I got them working again by changing code here https://github.com/ytake/Laravel.Smarty/blob/master/src/Smarty/Engines/SmartyEngine.php#L58
to not use the ob functions.

    protected function evaluatePath($path, array $data = [])
    {
        try {
            if (!$this->smarty->isCached($path)) {
                foreach ($data as $var => $val) {
                    $this->smarty->assign($var, $val);
                }
            }
            // render
            $cacheId = isset($data['smarty.cache_id']) ? $data['smarty.cache_id'] : null;
            $compileId = isset($data['smarty.compile_id']) ? $data['smarty.compile_id'] : null;
            return $this->smarty->fetch($path, $cacheId, $compileId);

        } catch (\Exception $e) {
            $this->handleViewException($e);
        }
    }

I am not sure what is causing this or why this fixes it.

accessing the Laravel-Session in $smarty.session

Dear all,
i like to share my .tpl files between projects with and without Laravel.
My last problem is to access the Laravel-Session-Variables in the template as $smarty.session...
I am aware that i can access it with session() inside the template, but i had to change a lot of templates.
so - my question is: would it be possible to add/change the behaviour of $smarty.session... ?
i found a possible candidate in smarty_internal_compile_private_special_variable.php, but i am not sure if it is the right place :)
kr Tom

Own plugin

Hello, is it possible and how to write my own plugin, which won't be in the default smarty plugin directory inside vendor folder, but samewhere inside app folder? Thanks

Call to undefined method Ytake\LaravelSmarty\Smarty::setTemplateDir()

Getting error:
Fatal error: Call to undefined method Ytake\LaravelSmarty\Smarty::setTemplateDir() in ProjectDir\vendor\ytake\laravel-smarty\src\SmartyFactory.php on line 203.

"laravel/framework": "5.0.*",
"ytake/laravel-smarty": "^2.1"

Want to render: resources/views/login.tpl
With cmd: \View::make('login')

Laravel 9 Support

Since Laravel 9 is now out, could the constraints be updated? ๐Ÿ‘๐Ÿป

Installing issue on Laravel 8.12

`Invalid argument supplied for foreach()

at vendor/ytake/laravel-smarty/src/SmartyFactory.php:214
210โ–•
211โ–• $smarty->error_reporting = Arr::get($config, 'error_reporting', E_ALL & ~E_NOTICE);
212โ–• // SmartyTemplate class for laravel
213โ–• $smarty->template_class = SmartyTemplate::class;
โžœ 214โ–• foreach ($config as $key => $value) {
215โ–• if (in_array($key, $this->configKeys)) {
216โ–• $smarty->{$key} = $value;
217โ–• }
218โ–• }

  +21 vendor frames 

22 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))`

somethings wrong in laravel6.0

notice me don't have function configure in bootstrap/app.php

image

and the Error: Fatal error: Uncaught Error: Call to undefined method Illuminate\Foundation\Application::configure() in /Users/dk/workspace/SGame/bootstrap/app.php:46 Stack trace: #0 /Users/dk/workspace/SGame/public/admin/index.php(39): require_once() #1 {main} thrown in /Users/dk/workspace/SGame/bootstrap/app.php on line 46

if i remove it.
image

i will get this error: Fatal error: Uncaught ReflectionException: Class config does not exist in /Users/dk/workspace/SGame/vendor/laravel/framework/src/Illuminate/Container/Container.php:803 Stack trace: #0

ytake-laravel-smarty.php config file has no effect

Hi!
Using Laravel 7.14.1 with Laravel.Smarty 4.0.0.
Changing the 'template_path' variable in ytake-laravel-smarty.php has no effect on loading view files from that path.
I had to change the path from config/view.php for it work. Is this expected behavior?

Same goes for the compile/cache path.

Artisan queue:work command does not clear assignments in mailables

In Version 6 and 7 there is an issue with assigned template variables in relation with the queue:work command.
Instead of queue:listen queue:work does not always boot Laravel so the existing Smarty Instance is kept.

Steps to reproduce

  1. Create two Mailables
  2. Create a simple smarty template where the variable is dumped
  3. Assign a variable only to the first mailable view
  4. Queue both Mails

Result in queue:listen: As expected, the variable gets only applied to the first mailable
Result in queue:work: The variable is dumped in both templates

Example files

App/Mail/TestMail1.php

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;

class TestMail1 extends Mailable
{
    use Queueable;

    public function build()
    {
        $this->view('mail.test', [
            'example' => 'assigned to first mailable'
        ]);

        return $this;
    }
}

App/Mail/TestMail2.php

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;

class TestMail2 extends Mailable
{
    use Queueable;

    public function build()
    {
        // "example" is not applied here
        $this->view('mail.test');

        return $this;
    }
}

templates/mail/test.tpl

<pre>{$example}</pre>

TestController.php

Mail::queue(new TestMail1());
Mail::queue(new TestMail2());

Required Changes

Smarty assignments have to be cleared on each Mailable.

In the current implementation, there is a risk that variables that are not overwritten by a second Mailable are erroneously transmitted in an email.

Notes

  • Tested with Laravel 9 and 10.
  • Smarty Caching false
  • Smarty Force Compile true
  • The test $variable is applied to all further mailables (even if the template file name differs)
  • This issue only occurs with Smarty templates, Blade templates are not affected

Run my views

Hello,

First I need to say this packge are awesome!

I have a doubt. All times I change a view I need to do
php artisan ytake:smarty-clear-cache
php artisan ytake:smarty-clear-compiled
php artisan ytake:smarty-optimize

Is this right? I really need to do it all times I change my views or have other way to refresh?

View composers not firing for included files

I have this simple test file...

<!-- base.tpl -->

{include file='main-nav.tpl'}

Then i have this view composer...

<?php

namespace App\Providers;

use App\Repositories\Eloquent\UsersRepository;
use Illuminate\Support\ServiceProvider;

class ViewComposerServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot(UsersRepository $users)
    {
        $this->app['view']->composer('main-nav', function ($view) use ($users) {
            $view->with('userCount', $users->count());
        });
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

...but it seems that view composer aren't fired for any files that are included like this.

Looking at the output of in Debugbar, the included main-nav.tpl doesn't get logged as rendered.

screen shot 2016-06-08 at 21 21 04

Update from Laravel 5.8 to 6.0 fails, illuminate/view required

Hi there,

I'm trying to update an old project but stucked from 5.8 to 6.0. It tells me that illuminate/view is required but that is replaced by Laravel 6.0.x

- ytake/laravel-smarty 2.5.0 requires illuminate/view 5.5.*|5.6.*|5.7.*|5.8.* -> satisfiable by illuminate/view[v5.5.0, ..., 5.8.x-dev].
- ytake/laravel-smarty 2.4.0 requires illuminate/view 5.5.*|5.6.*|5.7.* -> satisfiable by illuminate/view[v5.5.0, ..., 5.7.x-dev].
- Only one of these can be installed: illuminate/view[v5.5.0, ..., 5.8.x-dev], laravel/framework[v6.0.0, ..., v6.0.4]. laravel/framework replaces illuminate/view and thus cannot coexist with it.

How can I resolve this problem? I thought it is compatible with Laravel 8x as well?

Thanks for any help.

PHP 8 support

ytake/laravel-smarty 5.0.0 requires php ^7.3 -> your php version (8.0.5) does not satisfy that requirement.

Laravel 10 support

I see that there is a PR for this, could it be reviewed and merged so we can use this pckage with new Laravel version? Thank you in advance @ytake !

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.