Skip to content

Commit

Permalink
Clarify a couple things in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Sep 30, 2015
1 parent 9be949b commit 6f4763f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public function index()
}
```

> In Laravel 5, of course add `use JavaScript;` to the top of your controller.
Using the code above, you'll now be able to access `foo`, `user`, and `age` from your JavaScript.

```js
Expand All @@ -58,6 +60,18 @@ console.log(user); // User Obj
console.log(age); // 29
```

This package, by default, binds your JavaScript variables to a "footer" view, which you will include. For example:

```
<body>
<h1>My Page</h1>
@include ('footer') // <-- Variables prepended to this view
</body>
```

Naturally, you can change this default to a different view. See below.

### Defaults

If using Laravel, there are only two configuration options that you'll need to worry about. First, publish the default configuration.
Expand Down Expand Up @@ -143,6 +157,7 @@ Next, put it all together:
```php
$binder = new MyAppViewBinder;
$javascript = new PHPToJavaScriptTransformer($binder, 'window'); // change window to your desired namespace

$javascript->put(['foo' => 'bar']);
```

Expand Down

0 comments on commit 6f4763f

Please sign in to comment.