Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

quick proofreading

  • Loading branch information...
commit cf7b821395563fefdef0074455809b9bb22f7290 1 parent c8a5298
Yanick Champoux yanick authored
Showing with 17 additions and 17 deletions.
  1. +17 −17 danceradvent/public/articles/2012/your_own_DSL.pod
34 danceradvent/public/articles/2012/your_own_DSL.pod
View
@@ -1,21 +1,21 @@
=head1 Create your own Dancer 2 DSL
-As the previeous artiles explained it, Dancer 2 is a nice and shiny rewrite of
-Dancer 1, with a lot of benefits and strengths. One of them is that it's
+As the previous articles explained, Dancer 2 is a nice and shiny rewrite of
+Dancer 1, with a lot of added benefits and strengths. One of them is that it's
properly object oriented, thanks to L<Moo>.
-But the whole being cleanly designed, the Dancer's concepts are now objects,
+Thanks to that redesign of the framework, Dancer's core elements are now objects,
roles, or some kind of light factories. That is also true for Dancer DSL, which
-means that it can be extended or replaced altogether by one of your own !
+means that it can be extended or replaced altogether by one of your own!
But first, let's step back a bit.
-=head2 DSL-what ?
+=head2 DSL-what?
DSL means Domain-Specific Language (L<see
wikipedia|http://en.wikipedia.org/wiki/Domain-specific_language>). It's
basically what makes Dancer so easy to use. In our case it's a collection of
-keywords, that allows the developer to specify to Dancer what to do.
+keywords, which allows the developer to tell to Dancer what to do.
Let's look at a bit of code:
@@ -30,8 +30,8 @@ Let's look at a bit of code:
and halt;
}
-When you write that, we can count no less than 7 keywords used here! Dancer's
-DSL is everywhere in Dancer's powered application. If you actually wonder what
+The example above uses no less than 7 keywords! Dancer's
+DSL is everywhere in a Dancer-powered application. If you actually wonder what
the DSL keywords are in this example, they are : C<prefix>, C<get>,
C<to_dumper>, C<request>, C<hook>, C<dancer_app> and C<halt>.
@@ -41,12 +41,12 @@ Dancer's DSL is.
=head2 DSL-how ?
-How's the default DSL implemented ? It very simply lies in the package L<Dancer::Core::DSL>. You can look at the code L<here|https://github.com/PerlDancer/Dancer2/blob/master/lib/Dancer/Core/DSL.pm>.
+How's the default DSL implemented? It very simply lies in the package L<Dancer::Core::DSL>. You can look at the code L<here|https://github.com/PerlDancer/Dancer2/blob/master/lib/Dancer/Core/DSL.pm>.
-But basically it's a Moo class, that consumes the L<Dancer::Core::Role::DSL>
-role, and defines a list of keywords, and their implementations. Keywords are
+But, basically, it's a Moo class consuming the L<Dancer::Core::Role::DSL>
+role, and defining a list of keywords and their implementations. Keywords are
names, and the implementations are methods of the DSL class. The keywords can
-be of two kinds, the ones that can be called outside or inside a route, and the
+be of two kinds, the ones that can be called anywhere, and the
ones that can be called only inside a route. The implementations make heavily
usage of the other Dancer's concept, like the app, settings, sessions,
settings, and so on.
@@ -95,9 +95,9 @@ C<FrenchDSL>, that extends C<Dancer::Core::DSL>:
extends 'Dancer::Core::DSL';
-Pretty easy, right ? Now, let's see. We still want to benefit of all the
+Pretty easy, right? Now, let's see. We still want to benefit of all the
default keywords, but we want to add our translated ones. The keywords are
-defined by the dsl_keyword method, that returns them as an Array of Array. We
+defined by the C<dsl_keyword> method that returns them as an Array of Arrays. We
can use the C<around> method modifier of Moo to add our keywords at the end:
around dsl_keywords => sub {
@@ -115,8 +115,8 @@ can use the C<around> method modifier of Moo to add our keywords at the end:
return $keywords;
};
-The 1's and 0's mean that the keyword is global or can on ly be called from
-within a route code.
+The 1's and 0's indicate if the keywords are global or can only be called from
+within route code.
Third step: let's implement our new keywords. That's very easy because we are
just aliasing existing keywords:
@@ -155,7 +155,7 @@ C<use> time, in our application script:
dance;
We are coming to the end of the article. We hope that you have discovered that
-Dancer 2 allows easy and flexible exending, and that its guts are not that
+Dancer 2 allows easy and flexible extending, and that its guts are not that
complicated. The best advice would be: use Dancer 2 in new web developments,
and look at the code! it's not that big, and it's quite straightforward.
Please sign in to comment.
Something went wrong with that request. Please try again.