<?php
/**
 * Template loader with theme-override support.
 *
 * @package Vanquish\MultipleAddresses\Com
 */

namespace Vanquish\MultipleAddresses\Com;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Thin wrapper around wc_get_template() so templates can be overridden by the
 * theme in `yourtheme/vanquish-multiple-addresses/…` and default to the plugin's
 * own `templates/` folder.
 */
class Template {

	/**
	 * Theme sub-folder used to override the plugin templates.
	 */
	const THEME_PATH = 'vanquish-multiple-addresses/';

	/**
	 * Output a template.
	 *
	 * @param string $name Template file path, relative to templates/.
	 * @param array  $args Variables made available to the template.
	 * @return void
	 */
	public static function render( $name, array $args = array() ) {
		wc_get_template( $name, $args, self::THEME_PATH, VANMUAD_DIR . 'templates/' );
	}

	/**
	 * Return a template as a string.
	 *
	 * @param string $name Template file path, relative to templates/.
	 * @param array  $args Variables made available to the template.
	 * @return string
	 */
	public static function get( $name, array $args = array() ) {
		return wc_get_template_html( $name, $args, self::THEME_PATH, VANMUAD_DIR . 'templates/' );
	}
}
