PHPackages                             erick-arch-bit/nano-template-engine - 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. erick-arch-bit/nano-template-engine

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

erick-arch-bit/nano-template-engine
===================================

Un motor de plantillas ligero y rápido para microframeworks.

2.0.2(3mo ago)081MITPHPPHP ^8.2

Since Jan 4Pushed 1mo agoCompare

[ Source](https://github.com/Erick-arch-bit/Nano-Template-Engine)[ Packagist](https://packagist.org/packages/erick-arch-bit/nano-template-engine)[ RSS](/packages/erick-arch-bit-nano-template-engine/feed)WikiDiscussions dev Synced 1mo ago

READMEChangelogDependenciesVersions (8)Used By (1)

Nano Template Engine
====================

[](#nano-template-engine)

Un motor de plantillas para PHP ligero, rápido y con sintaxis inspirada en Blade. Diseñado para microframeworks, sin dependencias pesadas y con soporte nativo para Layouts y Componentes.

🚀 Características
-----------------

[](#-características)

- **Cero Dependencias:** Funciona con PHP nativo.
- **Alto Rendimiento:** Sistema de caché inteligente con invalidación de **OPcache** (solo recompila si la vista cambia).
- **Sintaxis Elegante:** Compatible con directivas de Blade (`{{ }}`, `@if`, `@foreach`).
- **🎨 Scoped CSS &amp; JS:** Estilos y scripts encapsulados nativamente (estilo Vue/Svelte).
- **📦 Frontmatter Imports:** Importa clases y define lógica al inicio del archivo (estilo Astro).
- **🧩 Componentes HTML:** Sintaxis moderna ``.
- **🌐 Datos Globales:** Comparte variables (`$user`, `$config`) con todas las vistas fácilmente.
- **Seguro:** Escapado automático de XSS en variables y modo `@verbatim` para Vue/Alpine.

📦 Instalación
-------------

[](#-instalación)

Instala el paquete vía Composer:

```
composer require erick-arch-bit/nano-template-engine
```

---

⚙️ Configuración Rápida
-----------------------

[](#️-configuración-rápida)

```
use Nano\TemplateEngine\Engine;

require 'vendor/autoload.php';

// 1. Instancia el Motor
$view = new Engine(
    viewsPath: __DIR__ . '/views',
    cachePath: __DIR__ . '/cache',
    extension: '.nano' // Extensión por defecto
);

// 2. (Opcional) Compartir datos globales con todas las vistas
$view->share('siteName', 'Mi App Increíble');
$view->share('user', $_SESSION['user'] ?? null);

// 3. Renderizar
echo $view->render('home', ['titulo' => 'Bienvenido']);
```

📖 Guía de Uso
-------------

[](#-guía-de-uso)

1. Frontmatter y Lógica (\_\_\_)

Separa tu lógica PHP del HTML usando bloques \_\_\_ al inicio del archivo. Soporta una sintaxis limpia de importación.

```
___
@use { User } from 'App\Models'
@use { Str } from 'Illuminate\Support'

$user = User::find(1);
$name = Str::upper($user->name);
___

Perfil de {{ $name }}
```

2. Scoped CSS &amp; JS (Encapsulamiento)

Define estilos y scripts que solo afectan al componente actual. Nano genera atributos únicos (data-n-xyz) y aísla el JS automáticamente.

Archivo: views/components/boton.nano

```

    {!! $slot !!}

    .btn { background: #3490dc; color: white; padding: 10px; border-radius: 5px; }

    const btn = document.querySelector('.btn');
    btn.addEventListener('click', () => console.log('Click en botón aislado'));

```

3. Componentes Modernos ()

Usa la sintaxis HTML nativa para renderizar componentes.

```

    Este es el contenido del slot principal.

```

4. Layouts y Stacks (Requerido)

Para que el CSS/JS Scoped funcione, debes agregar los stacks en tu layout maestro.

Archivo: views/layouts/app.nano

```
>

    @yield('title')
    @stack('nano_css')

    @yield('content')

    @stack('nano_scripts')

```

### 5. Utilidades y Helpers

[](#5-utilidades-y-helpers)

Nano incluye helpers para agilizar el desarrollo:

```
Clases Condicionales:

    ```html

        @yield('title')
        @stack('nano_css')

        @yield('content')

        @stack('nano_scripts')

    ```

Formularios:

    ```html

        @csrf              @method('PUT')

    ```

Ignorar Sintaxis (Vue/Alpine):

    ```html
    @verbatim
        {{ message }} @endverbatim
    ```

Inyección de Servicios:

    ```html
    @inject('metrics', 'App\Services\MetricsService')
    Visitas: {{ $metrics->count() }}
    ```

```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance83

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

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

Every ~1 days

Total

7

Last Release

118d ago

Major Versions

1.2.5 → 2.0.02026-01-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/71e0f38c933da1e70161365d74eeb922e1db66eb0a882f6d7c042066aa30c712?d=identicon)[Erick-arch-bit](/maintainers/Erick-arch-bit)

---

Top Contributors

[![Erick-arch-bit](https://avatars.githubusercontent.com/u/178329238?v=4)](https://github.com/Erick-arch-bit "Erick-arch-bit (17 commits)")

### Embed Badge

![Health badge](/badges/erick-arch-bit-nano-template-engine/health.svg)

```
[![Health](https://phpackages.com/badges/erick-arch-bit-nano-template-engine/health.svg)](https://phpackages.com/packages/erick-arch-bit-nano-template-engine)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[symfony/ux-icons

Renders local and remote SVG icons in your Twig templates.

545.8M69](/packages/symfony-ux-icons)

PHPackages © 2026

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