Closed sabracrolleton closed 10 years ago
Yes, a little non-obvious, isn't it? :) Sorry about that.
The first step is adjusting your defurl
expression to use named registers so that portions of the URL can be passed as parameters to your handle.
For example, i think if you rewrote your defurl
like this:
(defurl "^/find-country/(?<id>[0-9])/(?<name>[A-z])" :handler (find-country id name))
Then your handler would be called with the expected parameters, as hh-web extracts the named registers from the regex (e.g., the part between the <> characters) and treats that as a name, then takes whatever portion of the URL that matches the corresponding regex and passes that as a parameter with that name to the handler.
Also, because you declared the template with the :args (id name)
keyword argument, then in your template file (e.g., inside the page
expression) you can simplify refer to your arguments using the exact identifiers you specified in that :args
keyword: id
and name
.
Note that both id
and name
are likely already declared, so it's important that the packages for those symbols match in all cases. It could make sense to use as argument names country-id
and country-name
so that you can avoid clashes and be sure that you are referencing the correct symbols in all cases. That would mean your defurl
looks like this:
(defurl "^/find-country/(?<country-id>[0-9])/(?<country-name>[A-z])" :handler (find-country country-id country-name))
Hope this helps!
Thanks. That allowed me to figure it out. If you are interested, I now have an html5 tag library. I notice that hh-web is currently hard-coded for html 4.01.
Thats very cool!
Want to open a pull request?
:)
On Sep 10, 2014, at 10:04 PM, sabracrolleton notifications@github.com wrote:
Thanks. That allowed me to figure it out. If you are interested, I now have an html5 tag library. I notice that hh-web is currently hard-coded for html 4.01.
— Reply to this email directly or view it on GitHub https://github.com/hargettp/hh-web/issues/9#issuecomment-55210331.
Will in the very near future. Want to clean up a few things that I had done in my repo. Still trying to think about the best way to handle attributes required by javascript frameworks. Should there be an html5, an html5-backbone, html5-angularjs? I am trying to write up a walk-through (a little ajax, a little authentication, etc) that I will put on https://sites.google.com/site/sabraonthehill/, but will send you the draft beforehand for comments and corrections.
Sure! Take your time. Sounds like good stuff!
Re separate libraries: I think that could be a good idea. There may be folks who want to work with ordinary html5, but aren't motivated to take on angular, too. Keeping them separate let's them decide when to pull in the extra complexity.
Let me know if you run into any other bumps or warts!
:)
On Sep 10, 2014, at 10:18 PM, sabracrolleton notifications@github.com wrote:
Will in the very near future. Want to clean up a few things that I had done in my repo. Still trying to think about the best way to handle attributes required by javascript frameworks. Should there be an html5, an html5-backbone, html5-angularjs? I am trying to write up a walk-through (a little ajax, a little authentication, etc) that I will put on https://sites.google.com/site/sabraonthehill/, but will send you the draft beforehand for comments and corrections.
— Reply to this email directly or view it on GitHub https://github.com/hargettp/hh-web/issues/9#issuecomment-55211179.
I am trying to do something very basic but apparently not understanding defurl, handlers and the page macro. Can you give me an example where I just want to pass two parameters to a handler and the handler just returns the them as a string I cannot figure out what the defurl should look like or what I need to pass to the page macro.
First attempt at defurl (I want to pass either an integer (the country id in an array) or the name of the country (right now keeping it simple and ignoring multiword or hyphenated country names):
(defurl "^/find-country/(?[0-9])/(?[A-z] )" :handler (find-country id name))
(deftemplates :tag-library-packages (""hh-test") :template-packages (:hh-test) :templates ( (find-country-page "find-country.lisp" :args (id name)))
Then in a new file find-country.lisp I have no idea what to pass to the page macro. Any help or pointers would be appreciated.
Sabra