If you are logged-in and switch to the front-end the default WordPress theme Twenty Eleven
provides edit
buttons next to every post.
Pressing this button you get to the certain post’s back-end post edit page.
How to implement this into a custom template?
The function is
edit_post_link()
(see Codex or source). In TwentyEleven it used as follows incontent.php
You can simply use the function as indicated above (or in the Codex) in a custom template, but it must be used inside the loop. There’s no need to perform any permission checks.