Skip to content

Instantly share code, notes, and snippets.

@viankakrisna
Last active April 26, 2017 13:18
Show Gist options
  • Save viankakrisna/75941b5a7492a2ce80b93301389cb09a to your computer and use it in GitHub Desktop.
Save viankakrisna/75941b5a7492a2ce80b93301389cb09a to your computer and use it in GitHub Desktop.
php2jsx
var string = `copy your php here`
console.log(
string
.replace(/class=/g, 'className=')
.replace(/<\?php/g, '{')
.replace(/\?>/g, '}')
.replace(/echo/g, '')
.replace(/{ endif; }/g, '}')
.replace(/{ endif;}/g, '}')
.replace(/{endif; }/g, '}')
.replace(/{endif;}/g, '}')
.replace(/{ endif }/g, '}')
.replace(/{endif }/g, '}')
.replace(/{ endif}/g, '}')
.replace(/{endif}/g, '}')
.replace(/;/g, '')
.replace(/global $/g, 'global.')
.replace(/\$/g, 'props.')
.replace(/<br>/g, '<br />')
.replace(/<hr>/g, '<hr />')
.replace(/->/g, '.')
.replace(/if\((.*?)\):}/g, '$1 && ')
.replace(/if \((.*?)\):}/g, '$1 && ')
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment