-
-
Save vendethiel/1973798 to your computer and use it in GitHub Desktop.
sass+cs+haml vs. css+js+html
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
Translation of Google Maps Code (html + js) to haml + coffeescript | |
------------------------------------------------------------------- | |
assets/javascript/application.js | |
-------------------------------- | |
// | |
//= require jquery | |
//= require jquery_ujs | |
//= require_tree . | |
assets/javascript/maps.js.coffee | |
--------------------------------- | |
initialize = -> | |
latlng = new google.maps.LatLng(-34.397, 150.644) | |
myOptions = | |
zoom: 8 | |
center: latlng | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions) | |
$ -> initialize() | |
./view/application.html.haml | |
------------------------ | |
!!! 5 | |
%html | |
%head | |
%title Solar Map | |
= stylesheet_link_tag "application" | |
= javascript_include_tag "application" | |
= csrf_meta_tag | |
%meta{:content => "initial-scale=1.0, user-scalable=no", :name => "viewpoint"}/ | |
= javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false" | |
%body | |
= yield | |
./view/maps/index.html.haml | |
---------------------------- | |
#map_canvas{:style => "width:100%; height:100%"} | |
Google Code | |
-------------- | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | |
<style type="text/css"> | |
html { height: 100% } | |
body { height: 100%; margin: 0px; padding: 0px } | |
#map_canvas { height: 100% } | |
</style> | |
<script type="text/javascript" | |
src="http://maps.google.com/maps/api/js?sensor=set_to_true_or_false"> | |
</script> | |
<script type="text/javascript"> | |
function initialize() { | |
var latlng = new google.maps.LatLng(-34.397, 150.644); | |
var myOptions = { | |
zoom: 8, | |
center: latlng, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
var map = new google.maps.Map(document.getElementById("map_canvas"), | |
myOptions); | |
} | |
</script> | |
</head> | |
<body onload="initialize()"> | |
<div id="map_canvas" style="width:100%; height:100%"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment