task2-templating-demo

Task 2 - Templating Engine Demo πŸš€

Modern Web Development with Nunjucks + Vite

This project demonstrates the evolution from a simple Bootstrap demo (Task 1) to a sophisticated templating engine + bundler implementation using modern web development tools.

πŸ› οΈ Technology Stack

Chosen Technologies:

Why These Choices?

Nunjucks over Handlebars:

Vite over Gulp:

πŸ“‚ Project Structure

task2-templating-demo/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ templates/
β”‚   β”‚   β”œβ”€β”€ layouts/
β”‚   β”‚   β”‚   └── base.njk           # Base layout template
β”‚   β”‚   β”œβ”€β”€ partials/
β”‚   β”‚   β”‚   β”œβ”€β”€ navigation.njk     # Navigation component
β”‚   β”‚   β”‚   └── footer.njk         # Footer component
β”‚   β”‚   └── pages/
β”‚   β”‚       β”œβ”€β”€ index.njk          # Home page template
β”‚   β”‚       β”œβ”€β”€ about.njk          # About page template
β”‚   β”‚       └── contact.njk        # Contact page template
β”‚   └── assets/
β”‚       β”œβ”€β”€ css/
β”‚       β”‚   └── styles.css         # Custom styles
β”‚       β”œβ”€β”€ js/
β”‚       β”‚   └── main.js            # Main JavaScript file
β”‚       └── images/                # Image assets
β”œβ”€β”€ dist/                          # Compiled output
β”œβ”€β”€ package.json                   # Dependencies and scripts
β”œβ”€β”€ vite.config.js                 # Vite configuration
└── README.md                      # This file

πŸš€ Getting Started

Prerequisites

Installation & Setup

  1. Clone the repository
    git clone https://github.com/MANCHALA-SRAVAN-KUMAR/task2-templating-demo.git
    cd task2-templating-demo
    
  2. Install dependencies
    npm install
    
  3. Start development server
    npm run dev
    

    This will start the development server at http://localhost:3000 with hot reloading enabled.

  4. Build for production
    npm run build
    

    Compiled files will be generated in the dist/ directory.

  5. Preview production build
    npm run preview
    

Available Scripts

Script Description
npm run dev Start development server with hot reloading
npm run build Build for production with optimization
npm run preview Preview production build locally
npm run clean Clean the dist directory

🎯 Features

Template System

Development Experience

Production Ready

πŸ”§ Configuration

Vite Configuration (vite.config.js)

The project uses a custom Vite plugin to handle Nunjucks templates:

// Custom Nunjucks plugin for seamless integration
function nunjucksPlugin() {
  return {
    name: 'vite-plugin-nunjucks',
    configureServer(server) {
      // Development server with template rendering
    },
    generateBundle() {
      // Production build with template compilation
    }
  };
}

Template Configuration

Global variables available in all templates:

πŸ“± Responsive Design

The project maintains the responsive design from Task 1 while adding:

🎨 Styling

CSS Architecture

Bootstrap Integration

πŸ“Š Performance

Development

Production

πŸ§ͺ Testing & Validation

Manual Testing Checklist

Browser Support

πŸ“ˆ Comparison with Task 1

Aspect Task 1 (Bootstrap Demo) Task 2 (Templating + Bundler)
Architecture Static HTML files Component-based templates
Development Manual file editing Hot reloading with instant feedback
Maintainability Duplicated code DRY with template inheritance
Build Process None Optimized production builds
Scalability Limited Highly scalable architecture
Performance Basic Optimized with modern tooling

πŸš€ Deployment

GitHub Pages

  1. Build the project: npm run build
  2. Deploy the dist/ folder to GitHub Pages
  3. Configure GitHub Actions for automatic deployment

Netlify

  1. Connect your GitHub repository
  2. Set build command: npm run build
  3. Set publish directory: dist

Vercel

  1. Import your GitHub repository
  2. Framework preset: Vite
  3. Build command: npm run build
  4. Output directory: dist

πŸ“š Learning Resources

🀝 Contributing

This is an educational project, but suggestions and improvements are welcome:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘€ Author

MANCHALA-SRAVAN-KUMAR

πŸ™ Acknowledgments


Built with ❀️ using modern web development tools

This project demonstrates the power of combining templating engines with modern build tools to create maintainable, scalable web applications.