Skip to content
This repository was archived by the owner on Sep 23, 2022. It is now read-only.

Commit 763d84d

Browse files
committed
Add README.
1 parent 3372bb0 commit 763d84d

File tree

2 files changed

+131
-2
lines changed

2 files changed

+131
-2
lines changed

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Contributing to [chstudio/laravel-transclude](https://github.com/chstudio/laravel-transclude)
2+
3+
Every contribution is welcome; either by [submitting](https://github.com/chstudio/laravel-transclude/issues) bug issues or suggesting improvements, or in a more active form like [requesting](https://github.com/chstudio/laravel-transclude/pulls) a pull.
4+
5+
We want to collaborate happily, code joyfully, and get alive merrily. Thus, below are some guidelines, that we expect to be followed by each contributor.
6+
7+
- **Be brief, but be bold**. State your issues briefly. But speak out your ideas loudly, even if you can't or don't know how to implement it right away. The world will be better with limitless innovations.
8+
- **Test your code**. Nobody else knows your code better than you. So, it's completely yours mission to test the changes you made before pull request submission. We use [PHPUnit](https://phpunit.de/) for our testing purposes and recommend you using this tool too. [Here](https://phpunit.de/presentations.html) you can find PHPUnit best practices and additional information on effective unit testing, which helps us making laravel-transclude better day to day. Do not hesitate to smoke it carefully. It's a great investment in quality of your work, and it saves you years of life.
9+
- **Request pull in separate branch**. Do not submit your request to the master branch. But create a separate branch named specifically for the issue that you addressed. Read [GitHub manual](https://help.github.com/articles/using-pull-requests) to find out more about this. If you are new to GitHub, read [this short manual](https://help.github.com/articles/fork-a-repo) to get yourself familiar with forks and how git works in general. [This video](http://www.youtube.com/watch?v=-zvHQXnBO6c) explains how to synchronize your Github Fork with the Branch of laravel-transclude.
10+
11+
That's it. Thank you for your interest in WordPress, and welcome!
12+
13+
May the Force be with you.

README.md

Lines changed: 118 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,118 @@
1-
# laravel-transclude
2-
Allow to use Angular transclude features within Blade templates.
1+
# Laravel Transclude
2+
3+
[![Build Status](https://travis-ci.org/CHStudio/laravel-transclude.svg?branch=master)](https://travis-ci.org/CHStudio/laravel-transclude)
4+
[![Coverage Status](https://coveralls.io/repos/github/CHStudio/laravel-transclude/badge.svg?branch=master)](https://coveralls.io/github/CHStudio/laravel-transclude?branch=master)
5+
6+
This package allow to use [transclusion](https://en.wikipedia.org/wiki/Transclusion) from Blade template engines.
7+
It's very useful when you want to handle views as component. It's inspired by the Angular transclude logic.
8+
9+
Installing
10+
----------
11+
[![Latest Stable Version](https://img.shields.io/packagist/v/chstudio/laravel-transclude.svg)](https://packagist.org/packages/chstudio/laravel-transclude)
12+
[![Total Downloads](https://img.shields.io/packagist/dm/chstudio/laravel-transclude.svg)](https://packagist.org/packages/chstudio/laravel-transclude)
13+
14+
This project can be installed using Composer. Add the following to your `composer.json`:
15+
16+
```JSON
17+
{
18+
"require": {
19+
"chstudio/laravel-transclude": "~2.0"
20+
}
21+
}
22+
```
23+
24+
or run this command:
25+
26+
```Shell
27+
composer require chstudio/laravel-transclude
28+
```
29+
30+
After updating composer, add the `ServiceProvider` to the providers array in `config/app.php`.
31+
32+
### Laravel 5.x:
33+
34+
```php
35+
CHStudio\LaravelTransclude\TranscludeServiceProvider::class,
36+
```
37+
38+
Then you can use the new blade directives in your views !
39+
40+
Usage
41+
-----
42+
43+
This package register three new Blade directives :
44+
45+
* `@transclude` / `@endtransclude` to write inside a transcluded block,
46+
* `@transcluded` to declare a space where the transclusion will be written.
47+
48+
For example, take the [Bootstrap](http://getbootstrap.com/) form elements, they are all using the same global
49+
structure. Then in that structure there are different html blocks depending on the form element.
50+
51+
### Create template files
52+
53+
#### `input-group.blade.php`
54+
55+
```twig
56+
<div class="form-group">
57+
<label for="{{ $name }}" class="control-label">{{$label}}</label>
58+
59+
@transcluded
60+
</div>
61+
```
62+
63+
#### `radio.blade.php`
64+
65+
```twig
66+
@transclude('input-group')
67+
@foreach($options as $option)
68+
<div class="radio">
69+
<label>
70+
<input name="{{$name}}" type="radio" {{$option['value']==$selected?' checked':''}} value="{{$option['value']}}" />
71+
{{$option['label']}}
72+
</label>
73+
</div>
74+
@endforeach
75+
@endtransclude
76+
```
77+
78+
### Use the new blocks
79+
80+
Then after writing this 3 files, you can add an element using the `@include` directive :
81+
82+
```twig
83+
<form>
84+
@include('radio', [
85+
'options' => [
86+
['value' => '1', 'label' => 'Option 1']
87+
],
88+
'selected' => '1',
89+
'label' => 'My radio button'
90+
'name' => 'my-radio'
91+
])
92+
</form>
93+
```
94+
95+
This code will generate a full radio element with a combination of input-group and radio templates :
96+
97+
```html
98+
<form>
99+
<div class="form-group">
100+
<label for="my-radio" class="control-label">My radio button</label>
101+
102+
<div class="radio">
103+
<label>
104+
<input name="my-radio" type="radio" checked value="1" />
105+
Option 1
106+
</label>
107+
</div>
108+
</div>
109+
</form>
110+
```
111+
112+
## Contributing
113+
114+
We welcome everyone to contribute to this project. Below are some of the things that you can do to contribute.
115+
116+
- Read [our contributing guide](CONTRIBUTING.md).
117+
- [Fork us](https://github.com/chstudio/laravel-transclude/fork) and [request a pull](https://github.com/chstudio/laravel-transclude/pulls) to the [master](https://github.com/chstudio/laravel-transclude/tree/master) branch.
118+
- Submit [bug reports or feature requests](https://github.com/chstudio/laravel-transclude/issues) to GitHub.

0 commit comments

Comments
 (0)