move get_block_context api out of template into lib API