Giter Club home page Giter Club logo

compjs's Introduction

CompJS

A Lightweight HTML Component Library for Simplifying Code Structure

CompJS is a small JavaScript library designed to enhance HTML code organization by introducing a simple and effective way to create and use components.

Getting Started

To integrate CompJS into your project, add the following script tag at the end of your HTML file:

<script src="https://cdn.jsdelivr.net/gh/irdeako/compjs@main/comp.js"></script>

With this setup, you can leverage the power of components to make your HTML code more modular and maintainable.

Defining Components

Define components using the <define> tag. For example:

<define name="post" style="--color:var(--color)">
    <h2 style="--color:var(--color)">{{title}}</h2>
    <p>{{about}}</p>
</define>

In this example, we've created a component named "post" with placeholders for the title and about variables.

Using Components

To use a component, simply include its tag in your HTML code:

<post color="red" title="This is CompJS"
      about="You can learn how to work with CompJS by reading this post">
</post>

Specify variable values directly in the component tag to customize its content.

Variables and Default Values

Easily manage variable values within components. Set default values using the {{varName=defaultValue}} syntax. For instance:

<define name="htmlViewer">
    {{html}}
</define>
<htmlViewer msg="hello">
    <h2>Hello World!</h2>
    <button onclick="alert('{{msg=hi}}')">Click Here</button>
</htmlViewer>

Inserting Components

Insert components from external files into your code:

<define src="path/to/component" name="something"></define>
<something></something>

CompJS streamlines your code, making it more readable and maintainable.

Enjoy the Simplicity

CompJS is designed to simplify your HTML code, making it more modular and expressive. Enjoy a more efficient development experience with CompJS!

compjs's People

Contributors

codingwithenjoy avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.