bitpressio / blade-extensions Goto Github PK
View Code? Open in Web Editor NEWLaravel Blade Extension Classes for Laravel 5
License: MIT License
Laravel Blade Extension Classes for Laravel 5
License: MIT License
How can we pass an argument? Can anyone show an example?
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. :)
The composer.json
file needs to constrain the required illuminate packages and PHP version.
Illuminate
packages to composer.json
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 }}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.