Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. use Mojolicious::Lite;
  2. use Mojo::UserAgent;
  3. use Modern::Perl;
  4.  
  5. get '/' => sub {
  6.  
  7. # get this to render the hello tempalte
  8. my $ua = Mojo::UserAgent->new;
  9. my $self = shift;
  10.  
  11. # my $name =
  12. # $ua->get(
  13. #'http://api.powerhousemuseum.com/api/v1/category/xml/?api_key=8fbb61ea34d6f5d'
  14. # )->res->dom->find('result categories category:first-child name');
  15. # $self->render( 'hello', name => $name );
  16.  
  17. my $names = $ua
  18. ->get('http://api.powerhousemuseum.com/api/v1/category/xml/?api_key=8fbb61ea34d6f5d')->res->dom->result->categories;
  19.  
  20.  
  21.  
  22. #->res->dom
  23. #->result->categories->category->name;
  24.  
  25. $self->stash(name => $names);
  26. $self->render('hello');
  27.  
  28. };
  29.  
  30. #start the application
  31. app->start;
  32.  
  33. ## the rest of the file will be a template for markup
  34. ## Hello template:
  35. __DATA__
  36. @@ layouts/wrapper.html.ep
  37. <h1><%= title %></h1>
  38.  
  39. <%= content %> this is the layout wrapper<br>
  40.  
  41. % for my $name (@$names) {
  42. <li>
  43.  
  44. $name
  45.  
  46. </li>
  47. % }
  48. </ul>
  49.  
  50.  
  51. @@ hello.html.ep
  52. <h1>YO againnnnnn</h1>
  53. <%= $name %>
  54. <br>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement