Blocks... What are they anyway? You've probably used them without even realizing it and most certainly have seen them, but do you know what they are?
If we wanted to take a simplistic approach at defining a block we could say:
A block is a chunk of code contained within the
do..end
or { curly braces } syntax that is to be executed at some point in time.
With that being said, if you've ever used the Enumerable#map
or Enumerable#each
method, you've probably used a block. Lets take a look at two different types of blocks before we go into more detail about what a block really is.
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
var fs = require('fs'); | |
function csvParser(filePath) { | |
fs.readFile(filePath, 'utf8', function(err, data) { | |
if (err) { | |
throw err; | |
} else { | |
var result = []; | |
var lines = data.split('\n'); | |
var headings = lines[0].split(','); |
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
# add the email package | |
meteor add email |
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
<div id="main" role="main"> | |
<div class="container"> | |
<div class="row"> | |
<div class="span12" id="top-div"> <!--! added "top-div" id to help with ajax --> | |
<%= render 'layouts/messages' %> | |
<%= yield %> | |
</div> | |
</div> | |
<footer> | |
</footer> |
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
Meteor.startup(function() { | |
Template.fb_pic.pic = function() {// helper function to display the pic on the page | |
var userProfile; | |
userProfile = Meteor.user().profile; | |
if(userProfile) { // logic to handle logged out state | |
return userProfile.picture; | |
} | |
}; | |
}); |