Files
rspade_system/node_modules/@jqhtml/webpack-loader
root f6ac36c632 Enhance refactor commands with controller-aware Route() updates and fix code quality violations
Add semantic token highlighting for 'that' variable and comment file references in VS Code extension
Add Phone_Text_Input and Currency_Input components with formatting utilities
Implement client widgets, form standardization, and soft delete functionality
Add modal scroll lock and update documentation
Implement comprehensive modal system with form integration and validation
Fix modal component instantiation using jQuery plugin API
Implement modal system with responsive sizing, queuing, and validation support
Implement form submission with validation, error handling, and loading states
Implement country/state selectors with dynamic data loading and Bootstrap styling
Revert Rsx::Route() highlighting in Blade/PHP files
Target specific PHP scopes for Rsx::Route() highlighting in Blade
Expand injection selector for Rsx::Route() highlighting
Add custom syntax highlighting for Rsx::Route() and Rsx.Route() calls
Update jqhtml packages to v2.2.165
Add bundle path validation for common mistakes (development mode only)
Create Ajax_Select_Input widget and Rsx_Reference_Data controller
Create Country_Select_Input widget with default country support
Initialize Tom Select on Select_Input widgets
Add Tom Select bundle for enhanced select dropdowns
Implement ISO 3166 geographic data system for country/region selection
Implement widget-based form system with disabled state support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 06:21:56 +00:00
..

@jqhtml/webpack-loader

Webpack loader for JQHTML templates. Import .jqhtml files directly in your JavaScript!

Installation

npm install --save-dev @jqhtml/webpack-loader webpack
npm install @jqhtml/core jquery

Quick Start

1. Configure Webpack

Add the loader to your webpack.config.js:

module.exports = {
  module: {
    rules: [
      {
        test: /\.jqhtml$/,
        use: '@jqhtml/webpack-loader'
      }
    ]
  },
  resolve: {
    extensions: ['.js', '.jqhtml']
  }
};

Or use the configuration helper:

const { addJQHTMLSupport } = require('@jqhtml/webpack-loader');

module.exports = addJQHTMLSupport({
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: __dirname + '/dist'
  }
});

2. Create JQHTML Templates

Create UserCard.jqhtml:

<Define:UserCard>
  <div class="user-card">
    <h2 :text="name"></h2>
    <p :text="email"></p>
    <button @click="handleClick">Contact</button>
    
    <% if (this.data.showBio): %>
      <div class="bio" :html="bio"></div>
    <% endif; %>
  </div>
</Define:UserCard>

3. Import and Use

import UserCard from './UserCard.jqhtml';
import $ from 'jquery';

// Create component instance
const user = $('#user-container').component(UserCard, {
  name: 'John Doe',
  email: 'john@example.com'
});

// Set data
user.data = {
  name: 'John Doe',
  email: 'john@example.com',
  showBio: true,
  bio: '<p>Software developer</p>'
};

// Define methods
user.handleClick = function() {
  console.log('Contact clicked!');
  this.emit('contact', { user: this.data });
};

// Re-render to apply data
user.render();

Features

Multiple Components per File

<Define:Header>
  <header>
    <h1><%= this.data.title %></h1>
  </header>
</Define:Header>

<Define:Footer>
  <footer>
    <p>&copy; <%= this.data.year %></p>
  </footer>
</Define:Footer>

Import all components:

import { Header, Footer } from './Layout.jqhtml';
// Default export is the first component
import DefaultHeader from './Layout.jqhtml';

Data Bindings

Use :prop syntax for reactive bindings:

  • :text="expression" - Text content
  • :value="expression" - Input values
  • :class="{active: isActive}" - Dynamic classes
  • :style="{color: textColor}" - Dynamic styles
  • :html="htmlContent" - HTML content (use carefully)

Event Handlers

Use @event syntax for event handling:

  • @click="methodName" - Call component method
  • @change="updateValue" - Form events
  • @submit="handleSubmit" - Form submission

Scoped IDs

Use $id for component-scoped element IDs:

<div $id="content">
  <!-- Becomes id="content:abc123" where abc123 is the component's _cid -->
</div>

Access in component:

this.$id('content') // Returns jQuery element

Advanced Configuration

Loader Options

{
  test: /\.jqhtml$/,
  use: {
    loader: '@jqhtml/webpack-loader',
    options: {
      sourceMap: true  // Enable source maps (default: true)
    }
  }
}

With TypeScript

Add type declarations for .jqhtml imports:

// jqhtml.d.ts
declare module '*.jqhtml' {
  import { Component } from '@jqhtml/core';
  
  const component: typeof Component;
  export default component;
  
  // For multi-component files
  export const Header: typeof Component;
  export const Footer: typeof Component;
}

Production Build

The loader automatically handles production optimizations:

module.exports = {
  mode: 'production',
  module: {
    rules: [
      {
        test: /\.jqhtml$/,
        use: '@jqhtml/webpack-loader'
      }
    ]
  },
  optimization: {
    minimize: true
  }
};

How It Works

  1. Parse - The loader uses @jqhtml/parser to parse templates
  2. Generate - Converts templates to ES module code
  3. Export - Each component becomes an ES6 class export
  4. Register - Components are automatically registered globally

The generated code looks like:

import { Component, render_template, register_component } from '@jqhtml/core';

export class UserCard extends Component {
  static component_name = 'UserCard';
  
  async on_render() {
    const template_fn = function render() { /* ... */ };
    await render_template(this, template_fn);
  }
}

register_component('UserCard', UserCard);
export default UserCard;

Troubleshooting

Module Resolution

If webpack can't find .jqhtml files:

resolve: {
  extensions: ['.js', '.jqhtml'],
  modules: ['node_modules', 'src']
}

jQuery Not Found

Ensure jQuery is available:

plugins: [
  new webpack.ProvidePlugin({
    $: 'jquery',
    jQuery: 'jquery'
  })
]

Source Maps

For better debugging, ensure source maps are enabled:

devtool: 'source-map',
module: {
  rules: [{
    test: /\.jqhtml$/,
    use: {
      loader: '@jqhtml/webpack-loader',
      options: { sourceMap: true }
    }
  }]
}

Examples

See the /examples directory for complete examples:

  • Basic usage with vanilla JS
  • TypeScript integration
  • Multi-component layouts
  • Complex data binding scenarios

License

MIT