pug_dart library

A high-performance Dart wrapper for the Pug.js templating engine.

This library provides server-side Pug template rendering using a persistent Node.js server with Unix domain sockets for fast inter-process communication.

Quick Start

import 'package:pug_dart/pug_dart.dart';

main() async {
  var html = await pug.render('h1 Hello World');
  print('Rendered HTML: $html');
  await pug.dispose();
}

Features

  • High-performance persistent Node.js server
  • Unix domain socket communication (no port conflicts)
  • Type-safe File object support
  • Automatic Pug.js installation
  • Singleton pattern with automatic initialization
  • Comprehensive error handling
  • Cross-platform support (Linux, macOS, Windows fallback)

Classes

PugInstance
Singleton wrapper for Pug that automatically handles setup

Constants

pugFallbackScript → const String
Embedded pug_fallback.js script content
pugServerScript → const String
Embedded pug_server.js script content

Properties

pug PugInstance
Global pug instance for convenient access
final

Exceptions / Errors

PugServerException
Exception thrown when Pug server operations fail.