943,650 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 563
  • PHP RSS
Jan 12th, 2009
0

User configurable php preprocessor and generator - is there any???

Expand Post »
Hi,

I am looking for a free tool which let me write pure html + user defined special tags, which would be transformed on demand into php file. For example I can define source like this:

php Syntax (Toggle Plain Text)
  1. <html><body>
  2. <config/>
  3. <mysql>
  4. <form name="frm" action="nextstep.php">
  5. <select name="xxx">
  6. <query sql="select value, name from table where cathegory=@GET_cathegory";>
  7. <option value="%1">%2</option>
  8. </query>
  9. </select>
  10. </form>
  11. </mysql>
  12. </body></html>

result would be

php Syntax (Toggle Plain Text)
  1. <html><body>
  2. <?php
  3. include_once ("config.php");
  4. ?>
  5. <?
  6. include_once("mysql_open.php");
  7. ?>
  8. <form name="frm" action="nextstep.php">
  9. <select name="xxx">
  10. ....code what generates dynamically set of options....
  11. </select>
  12. </form>
  13. <?
  14. include_once("mysql_close.php");
  15. ?>
  16. </body></html>

is there such a tool???
Last edited by peter_budo; Jan 13th, 2009 at 5:19 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reputation Points: 10
Solved Threads: 9
Junior Poster
VIeditorlover is offline Offline
137 posts
since Dec 2007
Jan 12th, 2009
0

Re: User configurable php preprocessor and generator - is there any???

Actually your "pure html" example looks almost identical to ColdFusion from Adobe or, similarly, Genshi in Python.
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Jan 12th, 2009
0

Re: User configurable php preprocessor and generator - is there any???

Click to Expand / Collapse  Quote originally posted by ShawnCplus ...
Actually your "pure html" example looks almost identical to ColdFusion from Adobe or, similarly, Genshi in Python.
Yes, but cold fusion process page on runtime, but I need a code generator based on templates-samples which will be filles in XML-XSLT transformation style. Complicated parts will be written directly in PHP, but there are tons of stuff, which is nothing more than mechanical aplying design pattern and it can save time a lot + less bugs.
Reputation Points: 10
Solved Threads: 9
Junior Poster
VIeditorlover is offline Offline
137 posts
since Dec 2007
Jan 12th, 2009
0

Re: User configurable php preprocessor and generator - is there any???

Half of programming is learning to be an able toolsmith.

If no such tool exists, you'll have to make your own, perhaps using a pair of existing tools: sed and m4:[list][*]sed() transforms the input to a form m4() can understand[*]m4() 'replaces' the macros with suitable PHP code.

But then, isn't an SGML/XML processor is supposed to be able to handle this? If so, then if your input looked more like:
PHP Syntax (Toggle Plain Text)
  1. <html><body>
  2. <php_init_sql />
  3. <form name="frm" action="nextstep.php">
  4. <gen_select_sql name="xxx"
  5. cols="value, name"
  6. table="select_opts"
  7. match="@GET_cathegory"
  8. option_format=" &lt;option value=\"%1\"&gt;%2&lt;/option&gt;\n"
  9. />
  10. </form>
  11. <php_end_sql />
  12. </body></html>

then an XML processor should be able to produce the desired output. Here, <php_init_sql> is defined to output PHP code that handles the stuff done once-only in a PHP program (require-onces, includes, et al), including sql startup. <gen_select_sql> generates PHP code, that queries the DB and produces the complete <select>...</select>.

I think it all comes down to figuring out what you really want to accomplish. After that, it becomes straightforward and clear. Shoot, if the input is 'clean' enough, you could write shell scripts, awk scripts, perl scripts, sed scripts, even ex scripts to process it.
Reputation Points: 51
Solved Threads: 35
Posting Whiz in Training
Fest3er is offline Offline
238 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: General Date Convertor and Calculator (Simple)
Next Thread in PHP Forum Timeline: Calling all Web Design and Programer instructors and tutors.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC