1.0.1 • Published 9 months ago

bluscript v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

BluScript

Version: 1.0.1

A lightweight Domain-Specific Language (DSL) for generating web components.

Installation

npm install bluscript

Quick Start

import { Parser, HTMLGenerator } from 'bluscript';

const code = `
LOGIN PAGE {
  FIELD: username
  FIELD: password
  AUTH: JWT
  ACTION: /login
}
`;

const parser = new Parser(code);
const ast = parser.parse();
const htmlGenerator = new HTMLGenerator();

ast.forEach(command => {
  if (command.type === 'LOGIN') {
    const html = htmlGenerator.generateLoginPage(command);
    console.log(html);
  }
});

Syntax

LOGIN PAGE

Creates a login form with specified fields and configuration.

LOGIN PAGE {
  FIELD: username
  FIELD: password
  AUTH: JWT
  ACTION: /login
}

Parameters:

  • FIELD: Input field (can be specified multiple times)
  • AUTH: Authentication method
  • ACTION: Form submission endpoint

Generated HTML example:

<form action="/login" method="POST">
  <div class="form-group">
    <label for="username">Username</label>
    <input type="text" id="username" name="username" required>
  </div>
  <div class="form-group">
    <label for="password">Password</label>
    <input type="password" id="password" name="password" required>
  </div>
  <button type="submit">Login</button>
</form>

API Reference

Parser

const parser = new Parser(code);
const ast = parser.parse();

HTMLGenerator

const generator = new HTMLGenerator();
const html = generator.generateLoginPage(command);

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License - see the LICENSE file for details

1.0.1

9 months ago

0.1.0

9 months ago