Advertisement
Guest User

Untitled

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