Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pdrenderkit

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdrenderkit

A lightweight frontend rendering tool focusing on real-time DOM manipulation and flexible utilities for small to medium projects.

  • 1.5.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by41.67%
Maintainers
0
Weekly downloads
 
Created
Source

RenderJS

(Formerly known as PDRenderKit, renamed to RenderJS starting from version 2.0.0)

tag size license
npm download jsdeliver

RenderJS is a lightweight tool focusing on extending JavaScript native object prototypes, providing powerful DOM manipulation and data processing methods. It minimizes repetitive code and enhances development efficiency.

Feature

  • Simplified DOM Manipulation: Achieve complex DOM operations with concise chainable syntax.
  • Enhanced Querying: Quickly retrieve elements with simplified selector syntax, supporting both single and multiple element selection.
  • Built-in Extensions: Predefined prototype extensions accelerate development across various scenarios.
  • Plug and Play: Seamlessly integrates with existing JavaScript projects and supports modern browsers.

Installation

  • Install from npm

    npm i @pardnchiu/renderjs
    
  • Or include via CDN

    <!-- Version 2.0.0 and above -->
    <script src="https://cdn.jsdelivr.net/npm/@pardnchiu/renderjs@[VERSION]/dist/RenderJS.js"></script>
    
    <!-- Version 1.5.2 and below -->
    <script src="https://cdn.jsdelivr.net/npm/pdrenderkit@[VERSION]/dist/PDRenderKit.js"></script>
    

Overview

Extension

  • Before
    let section = document.createElement("section");
    section.id = "#test";
    document.body.appendChild(section);
    
    let button = document.createElement("button");
    button.style.width = "10rem";
    button.style.height = "2rem";
    button.style.backgroundColor = "steelblue";
    button.style.color = "fff";
    button.onclick = function(){
        alert("test")
    };
    button.innerHTML = "<span>test</span> button";
    section.appendChild(button);
    
    let svg = document.createElement("span");
    span.classList.add("svg");
    span.setAttribute("path", "https://xxxxxx");
    section.appendChild(span);
    
    let img = document.createElement("img");
    img.classList.add("lazyload");
    img.dataset.src = "https://xxxxxx";
    section.appendChild(img);
    
    let input = document.createElement("input");
    input.placeholder = "type";
    input.type = "email";
    section.appendChild(input);
    
  • After
    document.body._child(
        "section#test"._([
            "button"._({
                style: {
                    width: "10rem",
                    hright: "2rem",
                    backgroundColor: "steelblue",
                    color: "#fff"
                }
            }, [
                // or "<span>test</span> button"
                "span"._("test"),
                " button"
            ])._click(function(){
                alert("test")
            }),
            "span.svg:._({ path: "https://xxxxxx" }),
            // No Lazy Loading => "img"._("https://xxxxxx"),
            "img"._({ lazyload: "https://xxxxxx" }),
            "input@email type"._()
        ])
    );
    
    _Listener({
        svg: true,     // Add SVGListener, convert span.svg to svg tag
        lazyload: true // Add Lazy Listener, Lazy Loading images
    });
    
  • Get Element
    • Before
      document.getElementById("test");
      document.querySelector("div.test");
      document.querySelectorAll("div.test");
      document.querySelector("input[name='test']");
      
    • After
      "test".$;
      "div.test".$;
      "div.test".$all;
      "input[name='test']".$;
      
  • Add Element
    • Before
      <div class="test" style="width: 5rem; height: 80px;" test="test">
          <button>
              <img src="https://xxxxxx">
          </button>
      </div>
      
    • After
      "div.test"._({
          style: {
              width: "5rem",
              height: 80,
          },
          test: "test"
      }, [
          "button"._([
              "img"._("https://xxxxxx")
          ])
      ]);
      

Simplified Frontend Framework

[!NOTE] RJS is a simplified frontend framework based on QuickUI, designed for specific projects

  • Renders using non-vDOM technology, enhancing performance and reducing complexity.
  • Removes automatic listening and updating, giving developers manual control over update processes.
  • Introduces renew() function to support precise updates of data and events.
AttributeDescription
{{value}}Inserts text into HTML tags and automatically updates with data changes.
:pathUsed with the temp tag to load HTML fragments from external files into the current page.
:htmlReplaces the element's innerHTML with text.
:forSupports formats like item in items, (item, index) in items, (key, value) in object. Iterates over data collections to generate corresponding HTML elements.
:if
:else-if
:elif
:else
Displays or hides elements based on specified conditions, enabling branching logic.
:modelBinds data to form elements (e.g., input), updating data automatically when input changes.
:[attr]Sets element attributes, such as ID, class, image source, etc.
Examples: :id/:class/:src/:alt/:href...
:[css]Sets element CSS, such as margin, padding, etc. Examples: :background-color, :opacity, :margin, :top, :position...
@[event]Adds event listeners that trigger specified actions upon activation.
Examples: @click/@input/@mousedown...
  • Initializing RJS
    const app = "(ComponentID)".RJS({
        data: {
            // Define data
        },
        event: {
            // Define events
        },
        when: {
            before_render: function () {
                // Executes before rendering (can stop rendering)
                // return false 
            },
            rendered: function () {
                // Executes after rendering
            }
        }
    });
    
  • Updating RJS
    app.renew({
        // data: Only include data items to update; unmentioned items retain initial values.
        // event: Only include event items to update; unmentioned items retain initial values.
        // when: Only include lifecycle logic to update; unmentioned items retain initial logic.
    });
    

Creator

邱敬幃 Pardn Chiu

License

This source code project is licensed under the MIT license.


©️ 2022 邱敬幃 Pardn Chiu

Keywords

FAQs

Package last updated on 06 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc