GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - pug-php/js-phpize: Convert js-like syntax to standalone PHP code.

BranchesTags
Open more actions menu

Latest commit

 

History

247 Commits
247 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
examples
examples
 
 
src/JsPhpize
src/JsPhpize
 
 
tests
tests
 
 
.codeclimate.yml
.codeclimate.yml
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.styleci.yml
.styleci.yml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
phpunit.xml
phpunit.xml
 
 

Repository files navigation

JsPhpize

Latest Stable Version Build Status StyleCI Test Coverage Code Climate

Convert js-like syntax to standalone PHP code.

Install

In the root directory of your project, open a terminal and enter:

composer require js-phpize/js-phpize

Usage

Use compile to get PHP equivalent code to JavaScript input:

use JsPhpize\JsPhpize;

$jsPhpize = new JsPhpize();

echo $jsPhpize->compile('foo = { bar: { "baz": "hello" } }');

This code will output the following PHP code:

$foo = array( "bar" => array( "baz" => "hello" ) );

Or use render to execute it directly:

use JsPhpize\JsPhpize;

$jsPhpize = new JsPhpize();

$code = '
    // Create an object
    foo = { bar: { "baz": "hello" } };
    key = 'bar'; // instanciate a string

    return foo[key].baz;
';

$value = $jsPhpize->render($code);

echo $value;

This will display hello.

This library intend to is intended to allow js-like in PHP contexts (such as in template engines).

See the Phug documentation to see an implementation example as Pug expressions PHP converter.

And also check examples to see more examples (.js files are input examples js-phpize can handle and either .return show you what the engine will return for this code, or .php show you how it's compiled into PHP).

About

Convert js-like syntax to standalone PHP code.

Topics

convert-jsphptranspiler

Resources

Readme
MIT license
Activity
Custom properties

Stars

23 stars

Watchers

2 watching

Forks

3 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.