PHP Classes
elePHPant
Icontem

swam: Generate HTML from parsed SWAM markup text

Recommend this page to a friend!
  Info   View files Example   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-06-18 (2 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 59 All time: 9,673 This week: 327Up
Version License PHP version Categories
swam 1Custom (specified...5HTML, PHP 5, Parsers
Description Author

This package can generate HTML from parsed SWAM markup text.

It can take a string in the SWAM format and parses it to extract its structure.

The package can generate HTML output from the text defined in the SWAM format.

Name: Nicola Bombaci <contact>
Classes: 1 package by
Country: Italy Italy
Age: ???
All time rank: 4315174 in Italy Italy
Week rank: 911 Up46 in Italy Italy Up

 

Details

SWAM by Nicola Bombaci

Short Web Acronyms Merged

<img style="float:right" src="./swam.png">

Link to the official page - LICENSE

SWAM (Short Web Acronyms Merged) is a great alternative for the Front-End developers. HTML is often filled with tags that during large works, generate projects slow and difficult to understand, for this reason SWAM promises to catalog all the HTML tags to have a website backward compatible, fluid and dynamics. The language is python like and require the presence of the tabs. Every line is considered like a node of tree, who is on top is the father, who is under the father is a son and so on

Try the live code HERE

You can easily try the language and understand the syntax of SWAM. It's easy, it's fast, it could be yours. Let's click to discover. It's free

How to

Install

Download the project from Github and copy swam-min.php in your folder

Add in your php file the library

include './path/swam-min.php';

Get the contents from a file

$code = file_get_contents("./path/string.swa");

And print your parsed file

echo $swam->parse($code);

And this is it!

Programming

Every time you will create a new SWAM file (.swa), you can compile it only by pass through the piece of code into the class of swam and exectue the parsing $swam->parse($string). A little debugger will show you the status of your work.

There is a debug mode that you can easily activate, opening the file swam-min.php and at start you can see the variable $debug set on false. Turn on true and you can see how SWAM is working. It is very useful to check and fix some mistakes inside your code.

Comments

Write a comment is simple. It can just work only if you are using a whole line. The syntax used is like every language, you must use // and so on.

An example

> on div

>> // This line is a comment

>> on p

>>> Here I am

Be careful if you are typing a double slash inside a line with code, this will be removed and could cause error parsing

An example

> on p // I cannot stay here

>> Ops.

Structure

The on tag

In HTML to open some tag is used the syntax

<html></html>

In SWAM to open the tag you can easily use the syntax

> on html

Container

ON is a general container tag. It is helpful for every kind of tags like: div , section , form , p , and others. If you want to create a multilevel tag, you must start the new paragraph with one more tab than the previous element.

Example

> on div

>> on section

This will produce:

<div>
  <section></section>
</div>

In line

If you want to insert something inside an tag, you must start a new paragraph with one or more tabs than the previous element. You will write in the same tag until the number of tabs will be less than the father or a new tag has been inserted in.

Example

> on p

>> Hello World

>>> This is a test

>> on strong

>>> cool

> on h1

>> Here

This will produce:

<p>Hello World This a test <strong>cool</strong></p>
<h1>Here</h1>

Example

> on html

>> on head

>>> on title

>>>> SWAM

>> on body

>>> on p

>>>> Hello World

>>> on div

>>>> Nothing

This will produce:

<html>
    <head>
        <title>SWAM</title>
    </head>
    <body>
        <p>Hello World</p>
        <div>Nothing</div>
    </body>
</html>

JavaScripts

SWAM is fully compatible with JavaScript

> on script type="text/javascript"

>> var user = { >> name: 'Dolly'};

>>sprintf('Hello %(name)s', user);

Fast attributes

SWAM is fully backward compatible. You can use instead a ON tag, the same syntax of HTML.

> Example : on div id="new" style="margin-top:20em"

The important thing is use the white space only for declare a new value and the tab only for the row (the hierarchy of the nodes)

To give a fast input I've introduced 2 important symbol:

  1. #

    > This tag substitue the syntax id="myid" with #myid

  2. .

    > This tag substitue the syntax class="1stclass 2ndclass 3rd-class" with .1stclass.2ndclass.3rd-class

Example

> on html

>> on head

>>>on meta name="Welcome to SWAM"

>> on body

>>> on strong >>>> Example

>>> on section

>>>> on div #id1 >>>>> on p >>>>>> Section 1

>>>>> on div #id2 >>>>>> on p >>>>>>> Section 2

>>>>>> on div #id3 >>>>>>> on p style="color:white" >>>>>>>> Section 3

Results:

<html>
    <head>
        <meta name="Welcome to SWAM"
    </head>
    <body>
        <strong>Example</strong>
        <section>
            <div id="id1">
                <p>Section 1</p>
                <div id="id2">
                    <p>Section 2</p>
                    <div id="id3">
                        <p style="color:white">Section 3</p>
                    </div>
                </div>
            </div>
        </section>
    </body>
</html>
  Files folder image Files  
File Role Description
Files folder imageengine (4 files)
Files folder imageproj (2 files)
Accessible without login Plain text file .directory Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Image file swam.png Icon Icon image

  Files folder image Files  /  engine  
File Role Description
  Plain text file parser.php Class Class source
  Plain text file swam-min.php Class Class source
  Plain text file swam.php Class Class source
  Plain text file workit.php Class Class source

  Files folder image Files  /  proj  
File Role Description
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Accessible without login Plain text file string.swa Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:59
This week:0
All time:9,673
This week:327Up