npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@frogbob/inertia-vue-blade-directives

v1.0.3

Published

Implementing common blade-directives to internia-vue

Downloads

3

Readme

Common Blade-Directives for Internia.js Vue-Adapter

Inertia Vue Blade Directives

Docs

Prerequisites

Please note

In order to make these directives work, you have to share some data from laravel to vue via inertia-laravel-adapter. Just put this code into app/Providers/AppServiceProvider (or your custom Provider if you want) in boot-method:

use Inertia\Inertia;

...

Inertia::share([
    'auth' => function() {
        return auth()->check();
    },
    'csrf_token' => function() {
        return session()->get('_token');
    },
    'errors' => function() {
        return session()->get('errors', new MessageBag);
    }
]);

If you want to share other data with vue, feel free to add more data to share-array.

Or if you just want to make this package work you can install our helper-package Inertia Laravel Blade Share in your laravel system and you are good to go.

Installation

Install using NPM:

npm install @frogbob/inertia-vue-blade-directives

Install using Yarn:

yarn add @frogbob/inertia-vue-blade-directives

Implementing Directives

import InertiaVueBladeDirectives from '@frogbob/inertia-vue-blade-directives'
Vue.install(InertiaVueBladeDirectives);

Using Directives

Following directive-components are available for now. Hopefully many more will be available in future.

Auth <auth>

The directive may be used to quickly determine if the current user is authenticated:

<auth>Hi, you are logged in!</auth>

Guest <guest>

The directive may be used to quickly determine if the current user is a guest:

<guest>Hi guest!</guest>

Csrf <csrf>

Anytime you define an HTML form in your application, you should include a hidden CSRF token field in the form so that the CSRF protection middleware can validate the request. You may use the directive to include the token field:

<csrf/>

Maybe this is not a useful component since inertia-vue uses ajax for form-requests but for the sake of completeness we included this.

Method <method>

Type: PUT, PATCH, or DELETE

<method type="PUT"/>

Error <error>

The directive may be used to quickly check if validation error messages exist for a given attribute. Within an directive, you may echo the :MESSAGE variable to display the error message:

<error>
    <div class="alert alert-danger">:MESSAGE</div>
</error>

Closing line

Some will ask, why the heck you need vue-components, if you can access data by this.$page? We think inertia.js is awesome. But also we liked blade-directives. In our opinion its much more readable if you see whats going on in your code. If you use tons of this.$page statements in your code this could be a little confusing after a time.

<auth>Hi, Admin</auth> makes clear, all of it slot-content is only shown, if you are a authenticated user, right?

If you have suggestions for missing directives or better code feel free to make pull-requests. Or if you have found a bug, please create an issue and let us know.

Thank you!