Compose the Web, JWX-style!
JWX is a powerful, extensible component-based language that brings the flexibility of modern web frameworks into a familiar HTML-like syntax. Developed by JW Limited Ltd., JWX empowers developers to create dynamic, reusable components with ease.
.jwx
- Main JWX component files.jwxc
- JWX component library files (collections of components).jwxs
- JWX style files (for component-specific styles).jwxm
- JWX module files (for shared logic and utilities)
-
Intuitive Syntax: JWX uses an HTML-like syntax, making it easy for web developers to adopt and understand.
-
Dynamic Expressions: Embed dynamic content effortlessly with
{{ }}
expressions. -
Smart Control Structures: Use
@if
,@for
, and@switch
for powerful conditional rendering and loops. -
Scoped Styling: Keep your styles encapsulated with component-scoped CSS using
:component
. -
Lifecycle Scripts: Manage component behavior with init, methods, computed properties, and watchers.
-
Subcomponents: Build complex UIs by composing smaller, reusable components.
-
Global State Management: Easily share data across components with the built-in
$global
object. -
Helper Functions: Boost productivity with a rich set of built-in helpers.
JWX (JW eXtensible) is a cutting-edge component language that marries the simplicity of HTML with the power of modern web frameworks. Developed by JW Limited Ltd., JWX empowers developers to create dynamic, reusable, and maintainable web components with an intuitive syntax.
At its core, JWX extends HTML's familiar structure with powerful features like dynamic expressions, smart control structures, and scoped styling. This unique approach allows developers to build complex, interactive web applications using a template language that feels natural and easy to learn.
JWX shines in its ability to encapsulate component logic, styles, and structure in a single file, promoting a clean and organized codebase. With features like subcomponents, lifecycle scripts, and built-in state management, JWX scales effortlessly from simple widgets to full-fledged web applications.
Whether you're building a small interactive element or a large-scale web platform, JWX provides the tools and flexibility to bring your vision to life. Join the JWX revolution and experience the future of web component development!
- Components: The building blocks of JWX applications.
- Props: Input values that allow components to be customized.
- Expressions: Dynamic content embedded within components.
- Control Structures: Tools for conditional rendering and iteration.
- Scoped Styles: Component-specific CSS that doesn't leak.
- Lifecycle Scripts: Methods to control component behavior throughout its lifecycle.
- Subcomponents: Smaller, reusable pieces within larger components.
- Global State: A shared data store accessible across components.
Cmpiler Rules: (Here)
Components are defined using HTML-like syntax with special attributes and tags.
<div component="componentName" prop-propName="propDefinition">
<!-- Component content goes here -->
</div>
- The
component
attribute defines the component's name. - Props are defined using attributes prefixed with
prop-
.
Props are defined with a special syntax: prop-propName="defaultValue:type:validations"
defaultValue
: The default value for the prop. Use!
to mark as required.type
: The expected type of the prop (e.g., string, number, array).validations
: Additional validation rules, separated by|
.
Example:
<div component="userProfile" prop-age="!:number:min:18|max:120">
Component content can include static HTML and dynamic expressions.
- Use
{{ expression }}
for dynamic content. - Expressions can include prop values, methods, computed properties, and helpers.
Example:
<h1>{{ name | toUpperCase }}</h1>
<p>Age: {{ age }}</p>
The system supports various control structures for dynamic rendering.
@if(condition)
<!-- Content if true -->
@else
<!-- Content if false -->
@endif
@for(item in items)
<!-- Repeated content -->
@endfor
@switch(expression)
@case(value1)
<!-- Content for value1 -->
@case(value2)
<!-- Content for value2 -->
@default
<!-- Default content -->
@endswitch
Components can include subcomponents, which are reusable pieces within the main component.
<subcomponent name="subcomponentName">
<!-- Subcomponent content -->
</subcomponent>
Styles can be scoped to the component using the :component
selector.
<style>
:component {
/* Styles applied only to this component */
}
:component .class-name {
/* Styles for elements with class-name within this component */
}
</style>
Scripts provide additional functionality to components. They are defined using <script>
tags with specific component-script
attributes.
<script component-script="init">
// Code to run when the component is initialized
</script>
<script component-script="methods">
{
"methodName": function() {
// Method implementation
}
}
</script>
<script component-script="computed">
{
"computedPropName": function() {
// Computed property implementation
return someValue;
}
}
</script>
<script component-script="watch">
{
"watchedPropName": function(newValue, oldValue) {
// Code to run when watchedPropName changes
}
}
</script>
Event handling is done using the data-method
attribute.
<button data-method="methodName">Click me</button>
The system provides built-in helpers that can be used in expressions:
toUpperCase
,toLowerCase
: String transformationsformatDate
: Date formattingif
: Conditional helperforEach
: Array iteration- And more...
Example usage: {{ name | toUpperCase }}
Components can access and modify a global state object using $global
.
Example: {{ $global.someValue }}
This syntax allows for the creation of complex, interactive components with features similar to modern front-end frameworks, while maintaining a unique, HTML-based template structure.