| Author |
Message |
< Erlyweb mailing list ~ patch: create_components/2 and */3, notice plural, erlyweb.e |
| Guest |
Posted: Fri Jul 25, 2008 3:54 pm |
|
|
|
Guest
|
Aloha,
I created some convenience functions called
erlyweb:create_components/2 and erlyweb:create_components/3.
These work exactly like the singular variant erlweb:create_component/2
and /3. But in this case the plural functions accept lists of atoms in
the first parameter.
Like this:
LotsaComponents = [entry, category, tag].
erlyweb:create_components(LotsaComponents, "/projectX").
Options = [{magic, on}, {model, off}, {erltl, on}].
TonsaComponents = [header, tail].
erlyweb:create_components(TonsaComponents, "/projectX", Options).
==Patch starts here==
--- erlyweb.erl.bak 2008-07-25 15:51:01.000000000 +0200
+++ erlyweb.erl 2008-07-25 17:26:51.000000000 +0200
@@ -16,6 +16,8 @@
create_app/2,
create_component/2,
create_component/3,
+ create_components/3,
+ create_components/2,
compile/1,
compile/2,
out/1,
@@ -88,6 +90,29 @@
Other -> Other
end.
+%% @doc Create all files like the singular create_component/3 function
+%% but make multiple.
+%% @spec create_components
+%% ( Components::[ atom() | string() ]
+%% , AppDir::string()
+%% , Options::[option()])
+%% ->
+%% [ ok | {error, Err}]
+create_components (Components, AppDir, Options) ->
+ F = fun (C) ->
+ if
+ is_atom(C) -> atom_to_list(C);
+ true -> C
+ end
+ end,
+ [ create_component(F(Component), AppDir, Options) || Component <-
Components ].
+
+%% @doc Create all files like the singular create_component/2 function
+%% @equiv create_components (Components, AppDir, [{magic, on}, {model,
on}, {erltl, off}])
+create_components (Components, AppDir) ->
+ Options = [{magic, on}, {model, on}, {erltl, off}],
+ create_components (Components, AppDir, Options).
+
%% @doc Compile all the files for an application. Files with the '.et'
%% extension are compiled with ErlTL.
%%
==Patch ends here==
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---
Post received from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Fri Jul 25, 2008 6:52 pm |
|
|
|
Guest
|
I forgot to say that Yariv is welcome to incorporate it into the next
(minor-)version, but I'm not going to hold my breath for it.
Anyone who wants this feature (mass-production of components) is
welcome to it.
I made it because I got tired of typing erlyweb:create_component
multiple times for n components.
I guess one could also type:
[ erlyweb:create_component(atom_to_list(Component), "projectX",
Options) || Component <- [c1,c2,c3,...,cn]].
Take it or leave it. I do hope this contribution will be appreciated
by some people.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---
Post received from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Mon Jul 28, 2008 5:45 pm |
|
|
|
Guest
|
Thanks, I appreciate the contribution. I don't see any harm with
adding it to ErlyWeb
On Fri, Jul 25, 2008 at 11:52 AM, Buggaboo <buggasnoo@gmail.com> wrote:
>
> I forgot to say that Yariv is welcome to incorporate it into the next
> (minor-)version, but I'm not going to hold my breath for it.
>
> Anyone who wants this feature (mass-production of components) is
> welcome to it.
>
> I made it because I got tired of typing erlyweb:create_component
> multiple times for n components.
>
> I guess one could also type:
>
> [ erlyweb:create_component(atom_to_list(Component), "projectX",
> Options) || Component <- [c1,c2,c3,...,cn]].
>
> Take it or leave it. I do hope this contribution will be appreciated
> by some people.
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---
Post received from mailinglist |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|