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

ActiveLibrary

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

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

0.1(11mo ago)036UnlicensePHPPHP &gt;=8.0.0

Since Jun 13Pushed 11mo 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 1mo ago

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

26

—

LowBetter than 43% of packages

Maintenance52

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

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

333d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b195fbc0189fe712df53b3a0c4bdf91dc01a452b6af46ba1ff817f9f4199804b?d=identicon)[Bilbo](/maintainers/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

[nette/code-checker

✅ Nette CodeChecker: A simple tool to check source code against a set of Nette coding standards.

881.7M6](/packages/nette-code-checker)[contributte/translation

Symfony/Translation integration for Nette Framework.

771.8M37](/packages/contributte-translation)[tomaj/nette-api

Nette api

36261.8k4](/packages/tomaj-nette-api)[contributte/image-storage

Image storage for Nette framework

28749.3k1](/packages/contributte-image-storage)[contributte/mailing

Sending emails with pleasure and prepared templates.

16961.0k2](/packages/contributte-mailing)[contributte/latte

Extra contrib to nette/latte

111.5M2](/packages/contributte-latte)

PHPackages © 2026

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