PHPackages                             bilbofox/latte-asset-extension - 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. bilbofox/latte-asset-extension

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

bilbofox/latte-asset-extension
==============================

Extension for Latte v3 adding n:asset macro for simplification of asset render in Latte

0.1(1y ago)036UnlicensePHPPHP &gt;=8.0.0

Since Jun 13Pushed 1y ago1 watchersCompare

[ Source](https://github.com/BilboTav/LatteAssetExtension)[ Packagist](https://packagist.org/packages/bilbofox/latte-asset-extension)[ RSS](/packages/bilbofox-latte-asset-extension/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

LatteAssetExtension
===================

[](#latteassetextension)

Extension for Latte v3 adding `n:asset` macro for simplification of asset render (css/js files mainly) in Latte

Using macro is simple, we just add attribute `n:asset` or `n:src` to commonly used HTML tags `` or `` or ``. Macro automatically generates main argument for linking asset URL like `` and adds other arguments, if needed - for instance it will respect if argument `rel=""` in linking css style is present already. It will also prefix generated path by `{$basePath}` variable unless the linked URL is absolute.

For example when we use this in Latte:

```

```

Output looks like this:

```

```

Registering is simple by using Latte Neon DI extension:

```
latte:
    extensions: Bilbofox\Latte\AssetExtension
```

Formatters
----------

[](#formatters)

Main purpose of this extension is formatters - which can further manipulate final render of asset.

Formatter is any callable that is registered into extension by calling.

```
$assetExtension = new Bilbofox\Latte\AssetExtension;
$assetExtension->addFormatter(function (string $path): string {
    // ...

    return $path;
});
```

Callback receives original path as parameter and can modify it inside.

Library comes with existing formatters in form of invokable classes.

---

`Bilbofox\Latte\Formatters\VersionFormatter(int|string|callable $version)`Adds version to asset in form of query parameter `?v=` at the end.

Version can be number, string or callable recieving original path.

---

`Bilbofox\Latte\Formatters\FileVersionFormatter(string $wwwDir)`Extension of previous formatter which uses last modified timestamp of asset file as version - very useful when new assets files are deployed to production server - forces clients to reload browser cached assets.

Here we register extension with file version formatter:

```
latte:
    extensions:
         - @latteAssetExtension

latteAssetExtension:
    class: Bilbofox\Latte\AssetExtension
    setup:
        - addFormatter(Bilbofox\Latte\Formatters\FileVersionFormatter(%wwwDir%))
```

When we then use in Latte:

```

```

We get something like this:

```

```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance48

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

384d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/314932?v=4)[Bilbo](/maintainers/Bilbo)[@Bilbo](https://github.com/Bilbo)

---

Top Contributors

[![BilboTav](https://avatars.githubusercontent.com/u/868548?v=4)](https://github.com/BilboTav "BilboTav (5 commits)")

### Embed Badge

![Health badge](/badges/bilbofox-latte-asset-extension/health.svg)

```
[![Health](https://phpackages.com/badges/bilbofox-latte-asset-extension/health.svg)](https://phpackages.com/packages/bilbofox-latte-asset-extension)
```

###  Alternatives

[contributte/latte

Extra contrib to nette/latte

121.5M2](/packages/contributte-latte)[nepada/form-renderer

Latte template based form renderer for Nette forms with full support for Bootstrap 3, 4 &amp; 5.

11253.5k](/packages/nepada-form-renderer)[nextras/forms-rendering

Rendering helpers for Nette Framework Forms.

16103.8k2](/packages/nextras-forms-rendering)[webrouse/n-asset-macro

Asset macro for Latte and Nette Framework useful for assets cache busting (with gulp, webpack, etc.)

1264.6k1](/packages/webrouse-n-asset-macro)

PHPackages © 2026

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