Skip to content

cdmtn-dev/PrettyScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PrettyScript 0.0.1 Alpha

PrettyScript is a general-purpose language that extends JavaScript with additional functionality and syntax enhancements

Important

It's important to understand that this language is in its alpha version and is still very rough and unfinished. You can help with its development

How do I integrate it into my project?

Just a few lines of code. Since this is a prototype of the language, it doesn't yet support NPM. Therefore, you can integrate it by downloading it locally and embedding it via HTML. Take a look at index.html in the repository for a clear example:

<script src="/prettyscript/parser.js"></script>
<script>
    document.addEventListener("DOMContentLoaded", () => {
        PS.init("files/time.ps")
    })
</script>

Why do I need PrettyScript?

PrettyScript was created primarily to rethink certain approaches in classic JavaScript programming. It features convenient shorthands, built-in useful functions, and libraries. One example of a built-in library is “react”: it adds native reactivity support to your project. Here's an example (files/react.ps):

// react simple example

use async
use react
use cryptolib

include "./files/strict"

link("./files/css/main.css")

@app fn App() {
    const value = React.state("value", 0);
    const sets = React.state("sets", 0);

    const View: HTML = ViewComponent({ id: cryptolib.randomInt(1, 999), buttonText: "Add +1" });

    View.querySelector("#plus").on("click", () => {
        if value >= 9 {
            value.set(0)
            sets.set(sets + 1)
        }

        value.set(value + 1)
    });

    return View;
}

component ViewComponent {
    <div id={id}>
        <span#value>{value} / {sets}</span>
        <button#plus>{buttonText}</button>
    </div>
}

In this example, we create a View component, which we then configure so that clicking the button triggers a function that increments the counter by 1.

Follow me in telegram for updates

Contributors