php-form

command module
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2021 License: MIT Imports: 10 Imported by: 0

README

php-form

a lib that can modify the php code via javascript

Install

yarn add php-form

API

The full API for php-form is contained within the TypeScript declaration file

Example Usage


import {instance} from 'php-form'

(async () => {

  const form = await instance()

  let code = `<?php
  $form_email = [
    'label' => 'Email',
    'value' => 'user1@example.com',
  ];
  
  $form_name = 'billy'
  `
  
  const fields = await form.parse(code)
  // [{name: '$form_email', label: 'Email', value: 'user1@example.com'}, {name: '$form_name', value: 'billy'}]
  
  fields[0].value = 'user2@example.com'
  fields[1].value = 'magic'
  
  code = await form.stringify(fields)
  // <?php $form_email = [
  //   'label' => 'Email',
  //   'value' => 'user2@example.com',
  // ];
  // 
  // $form_name = 'magic'
})


License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL