Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze authored and AlexVanderbist committed Oct 7, 2018
1 parent 309f93d commit 5c8d0ff
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
24 changes: 19 additions & 5 deletions README.md
Expand Up @@ -59,23 +59,34 @@ The contents of a component can be stored in a simple Blade view.
Before using that component you must first register it. Typically you would do this in the `AppServiceProvider boot() method` or a service provider of your own

```php
BladeX::component('components.myAlert', 'my-alert')
BladeX::component('components.myAlert');
```

BladeX will automatically kebab-case your Blade view name and use that as the tag for your component. So for the example above the tag to use your component would be `my-alert`.

If you want to use a custom tag name use the `tag`-method.

```php
BladeX::component('components.myAlert')->tag('my-custom-tag');
```

You can also register an entire directory like this.

```php
// This will register all Blade views that are stored in `resources/views/components`

BladeX::components('components')
BladeX::component('components.*');
```

Or you can register multiple directories like this.

```php
// This will register all Blade views that are stored in both `resources/views/components` and `resources/views/layouts`

BladeX::components(['components', 'layouts'])
BladeX::component([
'components.*',
'layouts.*',
]);
```

In your Blade view you can now use the component using the kebab-cased name:
Expand Down Expand Up @@ -297,7 +308,7 @@ If you're using Vue components in combination with BladeX components, it might b
Setting a global prefix can easily be done before or after registering components:

```php
BladeX::component('components.myAlert', 'my-alert')
BladeX::component('components.myAlert');

BladeX::prefix('x');
```
Expand All @@ -313,7 +324,7 @@ All your registered components can now be used like this:
When you register a component

```php
BladeX::component('components.myAlert', 'my-alert')
BladeX::component('components.myAlert')
```
with this HTML

Expand All @@ -340,6 +351,9 @@ After that conversion Blade will compile (and possibly cache) that view.

Because all this happens before any HTML is sent to the browser, client-side frameworks like Vue.js will never see the original HTML you wrote (with the custom tags).

## Upgrading major versions

Please see [UPGRADING](UPGRADING.md) for more information on how to upgrade from one major version to the other.

## Testing

Expand Down
23 changes: 23 additions & 0 deletions UPGRADING.md
@@ -0,0 +1,23 @@
## From v1 to v2

The way components are registered is greatly simplified.

In `v1` you could pass a custom tag of your component as a second parameter. In `v2` you'll need to use the `tag` method.

```php
// v1
BladeX::component('components.myAlert', 'my-custom-tag')

// v2
BladeX::component('components.myAlert')->tag('my-custom-tag');
```

In v1 you could register an entire directory of components using the `components()` method. This method has now been deprecated. Use the `component` method and the `.*` notation to register a directory.

```php
// v1
BladeX::components('components');

// v2
BladeX::component('components.*');
```

0 comments on commit 5c8d0ff

Please sign in to comment.