January 30, 2012
On Monday, 30 January 2012 at 05:17:21 UTC, Andrei Alexandrescu wrote:
> The difficult part is integrating with Apache.

Eh, it's not so bad. Make a .htaccess file:

.htaccess:
===
Action dhp-script /cgi-bin/dhp
AddHandler dhp-script .dhp
===

Drop in your files.

hello.dhp
===
<?d cgi.write("Hello, world!"); ?>
===
NOTE: that is cgi.write, not writefln. This version uses
my cgi library so you have all those awesomesauce functions.


And in your cgi-bin folder, build dhp out of this
file:

http://arsdnet.net/dcode/dhp_cgi.d

And drop my cgi.d into your /tmp directory.
http://arsdnet.net/dcode/cgi.d

End result?

http://arsdnet.net/dhp/hello.dhp

works.


Of course, you'll see this is slow because it
runs the compiler every time. If it used rdmd instead
of dmd though, we'd get cache and it'd probably work
pretty decently. (My computer doesn't have rdmd set up
currently though.)
January 30, 2012
>>
>> I can't speak for Andrei, but I discovered after 4 years of university
>> that I
>> had become much better at learning new things.

>
> I believe that learning how to learn better is probably the most important thing to learn at the University.

Bullshit, bullshit, bullshit. All you need to learn how to learn is a library, not a $100k debt payable to useless pompous windbags. The biggest thing colleges teach is that their existence is actually needed for anything. And even *that* much is pure grade-A bullcrap.

Yea, you *can* learn such things at college: just like how I can sell you a $5k device to help you convert ice into water.


January 30, 2012
On Sun, Jan 29, 2012 at 10:35 PM, Nick Sabalausky <a@a.a> wrote:

> >>
> >> I can't speak for Andrei, but I discovered after 4 years of university
> >> that I
> >> had become much better at learning new things.
>
> >
> > I believe that learning how to learn better is probably the most
> important
> > thing to learn at the University.
>
> Bullshit, bullshit, bullshit. All you need to learn how to learn is a library, not a $100k debt payable to useless pompous windbags. The biggest thing colleges teach is that their existence is actually needed for anything. And even *that* much is pure grade-A bullcrap.
>
> Yea, you *can* learn such things at college: just like how I can sell you a $5k device to help you convert ice into water.
>
>
> Libraries don't give you deadlines (except for when to return your books)
or feedback on how well you are doing.
Some people need that.

--bb


January 30, 2012
On Sunday, 29 January 2012 at 23:25:36 UTC, Nick Sabalausky wrote:
> The whole industry's moved over keeping server-side code out of the HTML

So the whole industry has moved away from php? Sure templating is used so mixing php and html is as common, but if I'm not mistaken <? is still ?> used a lot, I don't know how to use PHP without it.


January 30, 2012
"Jesse Phillips" <jessekphillips+D@gmail.com> wrote in message news:ictwgryawpavhnrnqawa@dfeed.kimsufi.thecybershadow.net...
> On Sunday, 29 January 2012 at 23:25:36 UTC, Nick Sabalausky wrote:
>> The whole industry's moved over keeping server-side code out of the HTML
>
> So the whole industry has moved away from php?

I wish! No, it's moved away from using PHP in an ASP-classic-style. Ie, scattering a bunch of <?php ... ?> throughout an HTML document.

> Sure templating is used so mixing php and html is as common, but if I'm not mistaken <? is still ?> used a lot, I don't know how to use PHP without it.
>

Typically now, a PHP file will start with "<?php" to turn on "PHP-mode", and then it'll just leave PHP-mode on for the rest of the file. It won't even be closed with "?>" - this ensures no stray whitespace is printed, which can screw things up (for instance, if you're expecting that HTTP headers are not to have been sent yet.)


January 30, 2012
"Bill Baxter" <wbaxter@gmail.com> wrote in message news:mailman.202.1327961928.25230.digitalmars-d-announce@puremagic.com...
> On Sun, Jan 29, 2012 at 10:35 PM, Nick Sabalausky <a@a.a> wrote:
>
>> >>
>> >> I can't speak for Andrei, but I discovered after 4 years of university
>> >> that I
>> >> had become much better at learning new things.
>>
>> >
>> > I believe that learning how to learn better is probably the most
>> important
>> > thing to learn at the University.
>>
>> Bullshit, bullshit, bullshit. All you need to learn how to learn is a
>> library, not a $100k debt payable to useless pompous windbags. The
>> biggest
>> thing colleges teach is that their existence is actually needed for
>> anything. And even *that* much is pure grade-A bullcrap.
>>
>> Yea, you *can* learn such things at college: just like how I can sell you
>> a
>> $5k device to help you convert ice into water.
>>
>>
> Libraries don't give you deadlines (except for when to return your books)

Having deadlines doesn't need to cost $100k.

> or feedback on how well you are doing.

If you're relying on the tests to tell you how well you're doing, then you've already failed.

*You* are by far the best person to know whether *you* understand something or not. A school's evaluation is *NOT* for the student's sake - it's purely for the school's/teacher's own accountability. It's inherently innacurate, but needed anyway simply because they can't read your mind for an "I understand" or "I don't get it" - but you *can* read your own mind, so for the student, test results are extra time, extra money and *less* accurate, all for no benefit.

> Some people need that.
> 

January 31, 2012
On 2012-01-30 23:51, Jesse Phillips wrote:
> On Sunday, 29 January 2012 at 23:25:36 UTC, Nick Sabalausky wrote:
>> The whole industry's moved over keeping server-side code out of the HTML
>
> So the whole industry has moved away from php? Sure templating is used
> so mixing php and html is as common, but if I'm not mistaken <? is still
> ?> used a lot, I don't know how to use PHP without it.

This is used in Rails as well. I mean, you need a way to get a value from the controller into the view.

-- 
/Jacob Carlborg
January 31, 2012
"Jacob Carlborg" <doob@me.com> wrote in message news:jg84d8$1ea5$1@digitalmars.com...
> On 2012-01-30 23:51, Jesse Phillips wrote:
>> On Sunday, 29 January 2012 at 23:25:36 UTC, Nick Sabalausky wrote:
>>> The whole industry's moved over keeping server-side code out of the HTML
>>
>> So the whole industry has moved away from php? Sure templating is used so mixing php and html is as common, but if I'm not mistaken <? is still ?> used a lot, I don't know how to use PHP without it.
>
> This is used in Rails as well. I mean, you need a way to get a value from the controller into the view.
>

Right, but that's the extent of it. It's used for the HTML templates and not much else.


January 31, 2012
On Tuesday, 31 January 2012 at 07:14:48 UTC, Jacob Carlborg wrote:
> This is used in Rails as well. I mean, you need a way to get a value from the controller into the view.

Interestingly, a lot of PHP devs don't even use PHP for
this!

There's stuff like smarty in fairly wide use:

http://www.smarty.net/why_use


Though, of course, many PHP devs *do* use php for their
templates too. (including me when I do php w/o D. I like
the {$foo.bar} syntax in smarty but not the rest of it.)
January 31, 2012
On 2012-01-31 16:51, Adam D. Ruppe wrote:
> On Tuesday, 31 January 2012 at 07:14:48 UTC, Jacob Carlborg wrote:
>> This is used in Rails as well. I mean, you need a way to get a value
>> from the controller into the view.
>
> Interestingly, a lot of PHP devs don't even use PHP for
> this!
>
> There's stuff like smarty in fairly wide use:
>
> http://www.smarty.net/why_use
>
>
> Though, of course, many PHP devs *do* use php for their
> templates too. (including me when I do php w/o D. I like
> the {$foo.bar} syntax in smarty but not the rest of it.)

It seems like Smarty is used mostly because of PHP being quite verbose. This is not the case with Ruby and specially not with the help of the many view helpers the Rails framework provides out of the box.

Note also that Rails provides many different template languages as plugins. There could well be a smarty plugin.

Looking at the syntax comparisons: http://www.smarty.net/syntax_comparison

Late's make a comparison with two Rails template languages, Erb (the default) and HAML.

smarty:
{$foo}

erb:
<%= @foo >

haml:
= @foo

php:
<?=$foo['bar']?>

smarty:
{$foo.bar}

In Rails you would most likely pass an object instead of an array/hash.

erb:
<%= @foo.bar >

haml:
= @foo.bar

If you actually do pass a hash it will like this:

haml:
= @foo[:bar]

Or you can implement "method_missing" (like opDispatch) in the Hash class and get this syntax:

haml:
= @foo.bar

smarty:
{foreach $foo as $bar}

{/foreach}

erb:
<% @foo.each do |bar| %>
<% end %>

or

<% for bar in @foo %>
<% end %>

haml:
- @foo.each do |bar|
    # indent

smarty:
{for $x = 1 to 20 step 2}
  {$x}
{/for}

haml:
- (1 .. 20).step 2 do |x|
    = x

{$foo|lower|escape}

haml:
=h @foo.downcase

To me it looks like HAML wins in every example.

Don't know if Smarty has this feature but this is so cool in Rails:

= render @posts

What happens is @posts is an array of model objects of the type Post. Rails will look in the directory containing all view files for a directory called "posts". Then it will look for a partial named "_post.html.haml". It will render that partial passing in the element in the current iteration to the partial as "post".

In Rails you are free to do whatever you want in the views (not sure if you can access everything you need). But you are encouraged to keep the Ruby code to a minimum.

-- 
/Jacob Carlborg
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home