adonisjs / discussion

Discussing about new features and sharing random thoughts: ⚠️ Not every request will be accepted
51 stars 5 forks source link

Add stack/push/prepend to Edge #61

Closed pedzed closed 6 years ago

pedzed commented 6 years ago

It would be nice to have stacks, exactly like Laravel's Blade engine.

Related: https://laravel.com/docs/5.6/blade#stacks

Edge stacks

pedzed commented 6 years ago

prepending is not too important for me personally, but being able to push to a stack is really essential. For example, on some pages I might need jQuery, but on other pages I'd rather not include them.

thetutlage commented 6 years ago

The concept of stacks itself is too complicated, you can simply use sections here.

Master template

@section('scripts')
   <script src="1.js"></script>
   <script src="2.js"></script>
@endsection

Now let's say, you want one more script in a different template

@section('scripts')
   @super
    <script src="3.js"></script>
@endsection

@super will inherit from the master template and adds the 3rd one.