Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

In some cases files fail to compile but no error is emitted #13

Open
robframpton opened this issue Nov 30, 2016 · 3 comments
Open

In some cases files fail to compile but no error is emitted #13

robframpton opened this issue Nov 30, 2016 · 3 comments

Comments

@robframpton
Copy link
Collaborator

Say I have a .soy file with the following template and $results is not defined.

/**
 * @param? results
 */
{template .results}
	<div class="search-result-container">
		{foreach $result in $results}
			<span>{$result.title}</span>
		{/foreach}
	</div>
{/template}

The file will fail to compile but no errors are thrown notifying the developer that something has gone wrong.

If the template is fixed by checking for $results everything compiles fine.

/**
 * @param? results
 */
{template .results}
	<div class="search-result-container">
		{if $results}
			{foreach $result in $results}
				<span>{$result.title}</span>
			{/foreach}
		{/if}
	</div>
{/template}

It would be nice to know that one of my files failed to compile.

@mairatma
Copy link
Collaborator

Are you sure you're getting a compilation error? This should compile just fine, I checked it out now and had no problems. This should instead result in a runtime problem, since the javascript that this is compiled to will try to access a property in results, which is not defined.

@robframpton
Copy link
Collaborator Author

robframpton commented Nov 30, 2016

Here is my use case, it's a little unusual as it's using metal-ssg, so there is front-matter in the files and the .soyweb template is added automatically.

Here is the page that get's rendered to html.

Here is the component that is being rendered inside the search.soy page.

If you remove the check for $results and run gulp, the dist/docs/search.html page will not be generated.

@mairatma
Copy link
Collaborator

Ohhh I see, you're using the soyweb functionality to run soy through gulp, right? When there's an error like this gulp-soynode is not showing it to you, but is not generating the page either. That makes sense now, it may be either a problem with gulp-soynode or with soynode, which we call to do the rendering.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants