     new_lines = List.duplicate(?\n, line - state.line)
     key = length(state.quoted)
     placeholder = '__EEX__(' ++ Integer.to_charlist(key) ++ ');'
-    {current ++ placeholder ++ new_lines ++ chars,
-     %{state | quoted: [{key, state.engine.handle_end(buffer)} | state.quoted]}}
+    count = current ++ placeholder ++ new_lines ++ chars
+    new_state = %{state | quoted: [{key, state.engine.handle_end(buffer)} | state.quoted]}
+
+    {count, new_state}
   end
 
   # Look text ahead on expressions
 
-  defp look_ahead_text([{:text, text}, {:middle_expr, line, _, chars} | rest] = tokens, start, contents) do
+  defp look_ahead_text(
+         [{:text, text}, {:middle_expr, line, _, chars} | rest] = tokens,
+         start,
+         contents
+       ) do
     if only_spaces?(text) do
       {contents ++ text ++ chars, line, rest}
     else
       {contents, start, tokens}
     end
   end
+
   defp look_ahead_text([{:middle_expr, line, _, chars} | rest], _start, contents) do
     {contents ++ chars, line, rest}
   end
+
   defp look_ahead_text(tokens, start, contents) do
     {contents, start, tokens}
   end

  and the engine together by handling the tokens and invoking
  the engine every time a full expression or text is received.
  """
  @spec compile(String.t, keyword) :: Macro.t | no_return
  def compile(source, opts) when is_binary(source) and is_list(opts) do
    file = opts[:file] || "nofile"
    line = opts[:line] || 1
    trim = opts[:trim] || false
    case EEx.Tokenizer.tokenize(source, line, trim: trim) do
      {:ok, tokens} ->
        state = %{engine: opts[:engine] || @default_engine,
                  file: file, line: line, quoted: [], start_line: nil}
        init = state.engine.init(opts)
        generate_buffer(tokens, init, [], state)
      {:error, line, message} ->
        raise EEx.SyntaxError, line: line, file: file, message: message
    end

  end

  defp generate_buffer([], _buffer, _scope, state) do
    raise EEx.SyntaxError,
      message: "unexpected end of string, expected a closing '<% end %>'",
      file: state.file,
      line: state.line
  end

  # Creates a placeholder and wrap it inside the expression block
