1.0.8 • Published 10 months ago

php-htx-cli v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

htx-cli

A cli to convert htx files (components) to regular php.

Short example

Here is a small example with a page that has bootstrap and contains a button that displays a message and some text

src/pages/index.htx

<!-- import DefaultLayout from "../layouts/Default" -->
<!-- import "../other/HelloWorldButton" -->
<DefaultLayout title=strtoupper("Some Page")>
    <HelloWorldButton />
    <p>
        Some page
    </p>
</DefaultLayout>

src/layouts/Default.htx

<?php
if(!isset($props["title"])) $props["title"] = "Page";
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= $props["title"] ?></title>
    <SCOPES type="css" />

    <CSS src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" />
    <JS src="https://code.jquery.com/jquery-3.3.1.slim.min.js" />
    <JS src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js" />
    <JS src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js" />
</head>
<body>
    <INNER />
    <SCOPES type="js" />
</body>
</html>

src/other/HelloWorldButton.htx

<button type="button" class="btn btn-primary" onclick="helloWorldMessage()">Hello, World?</button>

src/other/HelloWorldButton.js

function helloWorldMessage(){
    alert("Hello, World!");
}

If you have Htx installed you can run the following to convert the code and run it with php. This uses the default settings, but they can be changed (see documentation)

htx
cd out
php -S localhost:3000
cd ../

Once it runs you should be able to open http://localhost:3000/

contributing

Feel free to contribute. Please be clear what you did and also why. Thank you for considering contributing

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago