PHPackages                             silber/client-templates - 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. silber/client-templates

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

silber/client-templates
=======================

Renders client templates from separate files into the main view of your application

v0.1(11y ago)131001PHPPHP &gt;=5.4.0

Since Dec 3Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/JosephSilber/client-templates)[ Packagist](https://packagist.org/packages/silber/client-templates)[ RSS](/packages/silber-client-templates/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Client Templates
----------------

[](#client-templates)

This package provides a simple mechanism for you to load up all your client template views into your main application view.

What? Why?
----------

[](#what-why)

Single page applications (SPAs) usually work by having the templates rendered on the client. For bigger applications, those templates might be loaded asynchronously as you need them. For smaller applications, it may make more sense to load all of your templates with the initial page load.

Since [HTML templates](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template) are pretty new and [not yet widely supported](http://caniuse.com/#search=templates), most frameworks rely on the templates being served within `script` tags, marked up with some special `type` attribute to indicate that it is in fact a template.

Using this package, you can keep your templates nicely organized, with each template in its own separate file. With one simple call, you can then inject all of your templates into your main application view.

Documentation
-------------

[](#documentation)

This is a framework-agnostic package. It also comes with special Laravel integration classes, but those are optional.

Begin by installing this package through Composer. Open your terminal to your project's root directory, and enter this at the prompt:

```
composer require "silber/client-templates:dev-master"

```

### Laravel Integration

[](#laravel-integration)

Once the composer installation completes, you can add the service provider and the alias. Open `app/config/app.php`, and make the following changes:

1. Add a new item to the `providers` array:

```
'Silber\Templates\Laravel\TemplatesServiceProvider'

```

2. Add a new item to the `aliases` array:

```
'Templates' => 'Silber\Templates\Laravel\TemplatesFacade'

```

That's it! You're all set to go.

### Usage

[](#usage)

Now that you're all set up, you can start by actually creating your templates. Within the `views` directory, create a new `templates` directory. This is where you will keep all of your templates.

Here's a sample directory structure:

[![A sample template directory structure](https://camo.githubusercontent.com/e81502586350fb702ed643785f1ceb65f709d6f1da283035908e6f99bc4d7760/687474703a2f2f692e696d6775722e636f6d2f5750506f4466412e706e67)](https://camo.githubusercontent.com/e81502586350fb702ed643785f1ceb65f709d6f1da283035908e6f99bc4d7760/687474703a2f2f692e696d6775722e636f6d2f5750506f4466412e706e67)

Within each of those files, you will have only the HTML for that particular template.

Then, within your main `index.blade.php` file - right before the closing `` tag - add this tiny piece of code:

```
{{ Templates::render('templates') }}

```

This will automatically render all of your templates, as follows:

```

```

You can now use these templates in your favorite JS framework!

Configuration
-------------

[](#configuration)

If you wish to change any of the package's default options, you will first need to publish the configuration file to your app's `config` directory. You can do this by running the following artisan command:

```
php artisan vendor:publish --provider="Silber\Templates\Laravel\TemplatesServiceProvider"

```

This will create a new config file at `config/templates.php`. You can now edit this file to change the default options.

### Template Type

[](#template-type)

By default, the `type` attribute is set to `text/ng-template`, which is what AngularJS uses. This can be changed in the package's configuration file. For example:

```
'type' => 'text/x-handlebars-template'
```

### Strip Extension

[](#strip-extension)

By default, the template file's extension will be stripped from the HTML `id` attribute. If you wish to leave it in there, set it to `false`:

```
'strip' => false
```

This will then output templates with their file's extension intact. For example:

```

```

### Exclude Pattern

[](#exclude-pattern)

Sometimes you may wish to exclude some files or directories from being rendered as their own templates:

```
'exclude' => '_includes'
```

### Views Directory

[](#views-directory)

By default, the base directory for the templates is in the views directory. If you wish to change that, you can do so by setting it here:

```
'views' => public_path('html')
```

Contributing
------------

[](#contributing)

Thank you for considering contributing! This project follows [Laravel's coding style](http://laravel.com/docs/4.2/contributions#coding-style).

### License

[](#license)

The `client-templates` package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance49

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4183d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22b26a325dcd437ae15f26d56e75cd8d7a09c016440cb247e179d1a648db7ecb?d=identicon)[silber](/maintainers/silber)

---

Top Contributors

[![JosephSilber](https://avatars.githubusercontent.com/u/1403741?v=4)](https://github.com/JosephSilber "JosephSilber (14 commits)")

---

Tags

laraveljavascripttemplates

### Embed Badge

![Health badge](/badges/silber-client-templates/health.svg)

```
[![Health](https://phpackages.com/badges/silber-client-templates/health.svg)](https://phpackages.com/packages/silber-client-templates)
```

###  Alternatives

[techguy/laravel-ckeditor

JavaScript WYSIWYG web text editor (for laravel).

1113.5k](/packages/techguy-laravel-ckeditor)[cornford/bootstrapper

An easy way to intergrate Twitter Bootstrap with Laravel.

232.7k](/packages/cornford-bootstrapper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
