Coder Social home page Coder Social logo

blade-extensions's Issues

Constant if expression?

I'd like to use this to alter the template output when it's being compiled based on a .env setting that's fixed at deployment. We have two news sites running on the same codebase, and a few pages are drastically altered by which site is being served. We compile the templates during deployment, and I'd like to fix those alterations in the compiled output so that the if condition is not checked during runtime. Do you know if this is possible?

In other words, I'd like to tell the Blade compiler to evaluate the if condition during compilation instead of injecting <php if ($constant_condition): ?> into the compiled template. I suspect I'll have to extend the compiler itself, but I'm hoping you've already thought of that. :)

how to pass params

  1 @php
  2 $array = array_fill(0, 10, 'hello');
  3 \Log::info($array);
  4 @endphp
  5 @wct ({{ $array }})
  6 
17     public function getDirectives()
 18     {
 19       \Log::info(__FUNCTION__);
 20       return [
 21         'wct' => [$this, 'getWechatContentTemplate']
 22       ];
 23     }
 24 

 33     public function getConditionals()
 34     {
 35         return [];
 36     }
 37 
 38     public function getWechatContentTemplate($values) {
 39       \Log::info($values);
 40       if(isset($values) && is_array($values) && array_key_exists('code', $values)) {
 41         $wct = Esl\WechatContentTemplate::where('code', $values['code'])->first();
 42         if(isset($wct)) {
 43           return $wct->content;
 44         } else {
 45           return '';
 46         }
 47       } else {
 48         return '';
 49       }
 50     }

the log is

[2020-03-21 17:28:36] local.INFO: {{ $array }}

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.