Javascript in Jade template

346 views
Skip to first unread message

David Holtzhouser

unread,
Dec 20, 2012, 12:53:14 PM12/20/12
to expre...@googlegroups.com
I'm very new to Node and Jade, so bare with my most likely simpleton question.

I'm wanting to work with the LinkedIn javascript API's.
As the doc's show:  http://developer.linkedin.com/documents/getting-started-javascript-api, you need to wrap the key:

<script type="text/javascript" src="http://platform.linkedin.com/in.js">
  api_key: your_api_key_goes_here
</script>

How can this be done with Jade templates?

Thanks,
Dave

Martin Wawrusch

unread,
Dec 20, 2012, 12:56:30 PM12/20/12
to expre...@googlegroups.com

David Holtzhouser

unread,
Dec 20, 2012, 1:02:35 PM12/20/12
to expre...@googlegroups.com
I found an html --> Jade converter here:


extends layout

script(type='text/javascript', src='http://platform.linkedin.com/in.js')
    api_key: xyzthanksandplease

block content
  h1= title
  p Welcome to #{title}

Unfortunately, when i look at the output using the tools in Chrome, I don't see the ref to the LinkedIn js.

<!DOCTYPE html><html><head><title>Express</title><link rel="stylesheet" href="/stylesheets/style.css"></head><body><h1>Express</h1><p>Welcome to Express</p></body></html>

David Holtzhouser

unread,
Dec 20, 2012, 1:06:19 PM12/20/12
to expre...@googlegroups.com
Thanks for the reply Martin.  I was probably typing my response to using that as you were responding.
Still don't see the linkedin js referenced in the rendered page as I would expect.

Martin Wawrusch

unread,
Dec 20, 2012, 1:06:20 PM12/20/12
to expre...@googlegroups.com
when you use a layout then only the blocks defined in layout are filled, everything else is ignored. Hence what you need to do in your layout.jade file is to create a block for your javascripts, then add a 

block javascripts
  script(type='text/javascript', src='http://platform.linkedin.com/in.js')
    api_key: xyzthanksandplease

to your page file.


--
You received this message because you are subscribed to the Google Groups "Express" group.
To view this discussion on the web visit https://groups.google.com/d/msg/express-js/-/2a9ZfgNrdCAJ.

To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/express-js?hl=en.



David Holtzhouser

unread,
Dec 20, 2012, 1:23:58 PM12/20/12
to expre...@googlegroups.com
Thank you.  That seems to have done the trick.
Just as a hopefully useful bit of information to anyone else trying to use the LinkedIn js api's, make sure if you're doing local testing to put in the proper info in the JavaScript API Domains: section.  I think this may have also been part of my issue.
lin.JPG
Reply all
Reply to author
Forward
0 new messages