PHPackages                             stillat/dagger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. stillat/dagger

ActiveLibrary[Templating &amp; Views](/categories/templating)

stillat/dagger
==============

v1.4.3(2mo ago)1941606MITPHPCI passing

Since Jan 20Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/Stillat/dagger)[ Packagist](https://packagist.org/packages/stillat/dagger)[ GitHub Sponsors](https://github.com/johnathonkoster)[ RSS](/packages/stillat-dagger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (18)Versions (22)Used By (0)

Dagger Components for Laravel Blade
===================================

[](#dagger-components-for-laravel-blade)

Dagger is a component authoring library for Laravel's Blade templating engine. Dagger components are heavily inspired by Laravel's [anonymous components](https://laravel.com/docs/blade#anonymous-components). Dagger's differentiating features are its compiler and expanded capabilities.

The Dagger compiler works hard to inline your component's code, perform various optimizations, as well as enable powerful new features, such as the [Attribute Cache](#attribute-cache), [Attribute Forwarding](#attribute-forwarding), and [Slot Forwarding](#slot-forwarding). The end result is a powerful, performant component authoring library with a familiar syntax.

The main visual difference when working with Dagger components is the use of the ` 'info', 'message'])

merge(['class' => 'alert alert-'.$type]) }}>
    {{ $message }}

```

```

```

- [Frequently Asked Questions](#frequently-asked-questions)
- [Installation](#installation)
- [Dagger Component View Paths](#dagger-component-view-paths)
    - [Index Components](#index-components)
    - [Moving Dagger Component Views](#moving-dagger-component-views)
- [Component Syntax and the Component Builder](#component-syntax-and-the-component-builder)
    - [Slots](#slots)
        - [Named/Scoped Slots](#namedscoped-slots)
        - [Checking if Slots Exist](#checking-if-slots-exist)
    - [Custom PHP When Using the Component Function](#custom-php-when-using-the-component-function)
    - [Calling Component Builder Methods](#calling-component-builder-methods)
    - [Renaming the Component Variable](#renaming-the-component-variable)
- [Data Properties/Attributes](#data-properties--attributes)
- [Notes on Conditional aware and props Directives](#notes-on-conditional-aware-and-props-directives)
- [Accessing Parent Data](#accessing-parent-data)
    - [Using the aware Directive](#using-the-aware-directive)
    - [Using the aware Builder Method](#using-the-aware-builder-method)
    - [Accessing Arbitrary Parent Data](#accessing-arbitrary-parent-data)
    - [Aware Variables and Attributes](#aware-variables-and-attributes)
- [Property Validation](#property-validation)
    - [Shorthand Validation Rules](#shorthand-validation-rules)
- [Compiler Attributes](#compiler-attributes)
    - [Escaping Compiler Attributes](#escaping-compiler-attributes)
- [Conditionally Rendering Components](#conditionally-rendering-components)
- [Rendering Components for Each Item in a List](#rendering-components-for-each-item-in-a-list)
    - [Automatically Inserting Prop Values](#automatically-inserting-prop-values)
    - [Inserting the Array Element as a Prop](#inserting-the-array-element-as-a-prop)
- [Caching Components](#caching-components)
    - [Dynamic Cache Keys](#dynamic-cache-keys)
    - [Specifying the Cache Store](#specifying-the-cache-store)
    - [Stale While Revalidate/Flexible Caching](#stale-while-revalidate-flexible-cache)
- [Component Name](#component-name)
- [Component Depth](#component-depth)
- [Attribute Forwarding](#attribute-forwarding)
    - [Nested Attribute Forwarding](#nested-attribute-forwarding)
    - [Variable Bindings and Attribute Forwarding](#variable-bindings-and-attribute-forwarding)
- [Slot Forwarding](#slot-forwarding)
    - [Nested Slot Forwarding](#nested-slot-forwarding)
- [Output Trimming](#output-trimming)
- [Stencils](#stencils)
    - [Rendering Default Stencil Content](#rendering-default-stencil-content)
    - [Additional Notes on Stencils](#additional-notes-on-stencils)
- [Mixins](#mixins)
    - [Mixin Methods](#mixin-methods)
    - [Accessing the Component Instance Inside Mixins](#accessing-the-component-instance-inside-mixins)
    - [Additional Notes on Mixins](#additional-notes-on-mixins)
- [Attribute Cache](#attribute-cache)
    - [Slot Variables and the Attribute Cache](#slot-variables-and-the-attribute-cache)
    - [Considerations](#considerations)
- [Static Template Optimizations](#static-template-optimizations)
- [Dynamic Components](#dynamic-components)
- [Custom Component Paths and Namespaces](#custom-component-paths-and-namespaces)
    - [Blade Component Prefix](#blade-component-prefix)
- [Compile Time Rendering](#compile-time-rendering)
    - [Disabling Compile Time Rendering on a Component](#disabling-compile-time-rendering-on-a-component)
    - [Enabling/Disabling Optimizations on Classes or Methods](#enablingdisabling-optimizations-on-classes-or-methods)
    - [Notes on Compile Time Rendering](#notes-on-compile-time-rendering)
- [Component Compiler Callbacks](#component-compiler-callbacks)
    - [Hanling Inner Content](#handling-inner-content)
    - [Wildcard Component Patterns](#wildcard-component-patterns)
- [The View Manifest](#the-view-manifest)
- [License](#license)

Frequently Asked Questions
--------------------------

[](#frequently-asked-questions)

- [How does the Dagger compiler differ from Laravel's component compiler?](#how-does-the-dagger-compiler-differ-from-laravels-component-compiler)
- [Is an additional build step required?](#is-an-additional-build-step-required)
- [Are class-based components supported?](#are-class-based-components-supported)
- [Will this magically make my existing Blade components faster?](#will-this-magically-make-my-existing-blade-components-faster)
- [Can I use regular Blade components with Dagger components?](#can-i-use-regular-blade-components-with-dagger-components)
- [Why are there JSON files in my compiled view folder?](#why-are-there-json-files-in-my-compiled-view-folder)
- [Are circular component hierarchies supported?](#are-circular-component-hierarchies-supported)
- [Why build all of this?](#why-build-all-of-this)

### How does the Dagger compiler differ from Laravel's component compiler?

[](#how-does-the-dagger-compiler-differ-from-laravels-component-compiler)

The Dagger compiler is a multi-stage compiler that recursively parses and compiles a component's template ahead of time. Components compiled with the Dagger compiler will become *part of the view's* compiled output. Because of this, Laravel's related view events will *not* be fired when Dagger components are loaded.

### Is an additional build step required?

[](#is-an-additional-build-step-required)

An additional build step is *not* required. Dagger components will be compiled the first time you load your views. [Dynamic Components](#dynamic-components) will be compiled automatically the first time they are encountered.

### Are class-based components supported?

[](#are-class-based-components-supported)

Dagger only supports anonymous components, and there are no plans to support class-based components at this time. However, you may use [Mixins](#mixins) to gain back some of the benefits of class-based components when authoring Dagger components.

### Will this magically make my existing Blade components faster?

[](#will-this-magically-make-my-existing-blade-components-faster)

No. The Dagger compiler only interacts with components using one of the registered component prefixes (`
