Last active
August 29, 2015 14:01
-
-
Save monnoval/1c5df8fe3113c7b944db to your computer and use it in GitHub Desktop.
Middleman - Append partial in page via javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| / Partial located inside layouts folder | |
| %ul | |
| %li= link_to 'Link One', '/' | |
| %li= link_to 'Link Two', '/' | |
| %li= link_to 'Link Thr', '/' | |
| %li= link_to 'Link For', '/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| / If there are parts in the page that can only be manipulated by js | |
| - anchor_links_html = partial "layouts/links" | |
| - anchor_links = anchor_links_html.gsub(/(\n|\t|\r)/, " ").gsub(/>\s*</, "><") | |
| :javascript | |
| $(document).ready(function(){ | |
| $("#selector").append("#{anchor_links}"); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment